mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Introduce an AppMediator which will:
- combine multiple services to handle app wide requests - remove direct UIApplication access from everywhere - fix #2703 by combining UIApplication.applicationState with the WindowManager's main window appearance - leave the door open for more app control in the future (especiall for the mac)
This commit is contained in:
committed by
Stefan Ceriu
parent
bdacea10a2
commit
9a172df7fd
@@ -24,19 +24,9 @@ class BackgroundTaskTests: XCTestCase {
|
||||
static let bgTaskName = "test"
|
||||
}
|
||||
|
||||
func testInAnExtension() {
|
||||
let service = UIKitBackgroundTaskService {
|
||||
nil
|
||||
}
|
||||
let task = service.startBackgroundTask(withName: Constants.bgTaskName)
|
||||
|
||||
XCTAssertNil(task, "Task should not be created")
|
||||
}
|
||||
|
||||
func testInitAndStop() {
|
||||
let service = UIKitBackgroundTaskService {
|
||||
ApplicationMock.default
|
||||
}
|
||||
let service = UIKitBackgroundTaskService(appMediator: AppMediatorMock.default)
|
||||
|
||||
guard let task = service.startBackgroundTask(withName: Constants.bgTaskName) else {
|
||||
XCTFail("Failed to setup test conditions")
|
||||
return
|
||||
@@ -52,9 +42,7 @@ class BackgroundTaskTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testNotReusableInit() {
|
||||
let service = UIKitBackgroundTaskService {
|
||||
ApplicationMock.default
|
||||
}
|
||||
let service = UIKitBackgroundTaskService(appMediator: AppMediatorMock.default)
|
||||
|
||||
// create two not reusable task with the same name
|
||||
guard let task1 = service.startBackgroundTask(withName: Constants.bgTaskName),
|
||||
@@ -69,9 +57,7 @@ class BackgroundTaskTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testReusableInit() {
|
||||
let service = UIKitBackgroundTaskService {
|
||||
ApplicationMock.default
|
||||
}
|
||||
let service = UIKitBackgroundTaskService(appMediator: AppMediatorMock.default)
|
||||
|
||||
// create two reusable task with the same name
|
||||
guard let task1 = service.startBackgroundTask(withName: Constants.bgTaskName, isReusable: true),
|
||||
@@ -90,9 +76,7 @@ class BackgroundTaskTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testMultipleStops() {
|
||||
let service = UIKitBackgroundTaskService {
|
||||
ApplicationMock.default
|
||||
}
|
||||
let service = UIKitBackgroundTaskService(appMediator: AppMediatorMock.default)
|
||||
|
||||
// create two reusable task with the same name
|
||||
guard let task = service.startBackgroundTask(withName: Constants.bgTaskName, isReusable: true),
|
||||
@@ -113,9 +97,7 @@ class BackgroundTaskTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testNotValidReuse() {
|
||||
let service = UIKitBackgroundTaskService {
|
||||
ApplicationMock.default
|
||||
}
|
||||
let service = UIKitBackgroundTaskService(appMediator: AppMediatorMock.default)
|
||||
|
||||
// create two reusable task with the same name
|
||||
guard let task = service.startBackgroundTask(withName: Constants.bgTaskName, isReusable: true) else {
|
||||
@@ -135,9 +117,7 @@ class BackgroundTaskTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testValidReuse() {
|
||||
let service = UIKitBackgroundTaskService {
|
||||
ApplicationMock.default
|
||||
}
|
||||
let service = UIKitBackgroundTaskService(appMediator: AppMediatorMock.default)
|
||||
|
||||
// create two reusable task with the same name
|
||||
guard let task = service.startBackgroundTask(withName: Constants.bgTaskName, isReusable: true) else {
|
||||
@@ -161,9 +141,7 @@ class BackgroundTaskTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testBrokenApp() {
|
||||
let service = UIKitBackgroundTaskService {
|
||||
ApplicationMock.mockBroken
|
||||
}
|
||||
let service = UIKitBackgroundTaskService(appMediator: AppMediatorMock.mockBroken)
|
||||
|
||||
// create two reusable task with the same name
|
||||
let task = service.startBackgroundTask(withName: Constants.bgTaskName)
|
||||
@@ -172,9 +150,7 @@ class BackgroundTaskTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testNoTimeApp() {
|
||||
let service = UIKitBackgroundTaskService {
|
||||
ApplicationMock.mockAboutToSuspend
|
||||
}
|
||||
let service = UIKitBackgroundTaskService(appMediator: AppMediatorMock.mockAboutToSuspend)
|
||||
|
||||
// create two reusable task with the same name
|
||||
let task = service.startBackgroundTask(withName: Constants.bgTaskName)
|
||||
|
||||
@@ -32,7 +32,7 @@ class PillContextTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -61,7 +61,7 @@ class PillContextTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -83,7 +83,7 @@ class PillContextTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
|
||||
@@ -202,6 +202,7 @@ class RoomFlowCoordinatorTests: XCTestCase {
|
||||
roomTimelineControllerFactory: MockRoomTimelineControllerFactory(),
|
||||
navigationStackCoordinator: navigationStackCoordinator,
|
||||
emojiProvider: EmojiProvider(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
|
||||
@@ -56,7 +56,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -93,7 +93,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -128,7 +128,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -160,7 +160,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -192,7 +192,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -221,7 +221,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -249,7 +249,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -277,7 +277,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -305,7 +305,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
@@ -425,7 +425,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: notificationCenter)
|
||||
@@ -451,7 +451,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
|
||||
@@ -50,6 +50,7 @@ class UserSessionFlowCoordinatorTests: XCTestCase {
|
||||
appLockService: AppLockServiceMock(),
|
||||
bugReportService: BugReportServiceMock(),
|
||||
roomTimelineControllerFactory: MockRoomTimelineControllerFactory(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
notificationManager: notificationManager,
|
||||
|
||||
Reference in New Issue
Block a user