mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
Replace the existing MockClientProxy with a generated one + special configuration options
This commit is contained in:
@@ -885,6 +885,7 @@
|
|||||||
DC1BB5EE5F4D9B6A1F98A77A /* WelcomeScreenScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEC2E8E1B20BB2EA07B0B61E /* WelcomeScreenScreenViewModel.swift */; };
|
DC1BB5EE5F4D9B6A1F98A77A /* WelcomeScreenScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEC2E8E1B20BB2EA07B0B61E /* WelcomeScreenScreenViewModel.swift */; };
|
||||||
DC68E866D6E664B0D2B06E74 /* MockImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC1DA29A5A041CC0BACA7CB0 /* MockImageCache.swift */; };
|
DC68E866D6E664B0D2B06E74 /* MockImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC1DA29A5A041CC0BACA7CB0 /* MockImageCache.swift */; };
|
||||||
DDB47D29C6865669288BF87C /* UIFont+AttributedStringBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = E8CA187FE656EE5A3F6C7DE5 /* UIFont+AttributedStringBuilder.m */; };
|
DDB47D29C6865669288BF87C /* UIFont+AttributedStringBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = E8CA187FE656EE5A3F6C7DE5 /* UIFont+AttributedStringBuilder.m */; };
|
||||||
|
DDFBDEE1DC32BDD5488F898C /* ClientProxyMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F96CCBEAAA7F2185BFA354 /* ClientProxyMock.swift */; };
|
||||||
DE4F8C4E0F1DB4832F09DE97 /* HomeScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D6764D6976D235926FE5FC /* HomeScreenViewModel.swift */; };
|
DE4F8C4E0F1DB4832F09DE97 /* HomeScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D6764D6976D235926FE5FC /* HomeScreenViewModel.swift */; };
|
||||||
DF004A5B2EABBD0574D06A04 /* SplashScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 854BCEAF2A832176FAACD2CB /* SplashScreenCoordinator.swift */; };
|
DF004A5B2EABBD0574D06A04 /* SplashScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 854BCEAF2A832176FAACD2CB /* SplashScreenCoordinator.swift */; };
|
||||||
DF05F9C9D3D977EB77E13692 /* DeviceKit in Frameworks */ = {isa = PBXBuildFile; productRef = 385D4C28F9DC5CF53BD9ECDB /* DeviceKit */; };
|
DF05F9C9D3D977EB77E13692 /* DeviceKit in Frameworks */ = {isa = PBXBuildFile; productRef = 385D4C28F9DC5CF53BD9ECDB /* DeviceKit */; };
|
||||||
@@ -952,7 +953,6 @@
|
|||||||
ED90A59F068FD0CA27E602ED /* UserProfileListRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E10DA51DBC8C7E1460DBCCBD /* UserProfileListRow.swift */; };
|
ED90A59F068FD0CA27E602ED /* UserProfileListRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E10DA51DBC8C7E1460DBCCBD /* UserProfileListRow.swift */; };
|
||||||
EDF8919F15DE0FF00EF99E70 /* DocumentPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F5567A7EF6F2AB9473236F6 /* DocumentPicker.swift */; };
|
EDF8919F15DE0FF00EF99E70 /* DocumentPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F5567A7EF6F2AB9473236F6 /* DocumentPicker.swift */; };
|
||||||
EE4E2C1922BBF5169E213555 /* PillAttachmentViewProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B53D6C5C0D14B04D3AB3F6E /* PillAttachmentViewProvider.swift */; };
|
EE4E2C1922BBF5169E213555 /* PillAttachmentViewProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B53D6C5C0D14B04D3AB3F6E /* PillAttachmentViewProvider.swift */; };
|
||||||
EE4F5601356228FF72FC56B6 /* MockClientProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F40F48279322E504153AB0D /* MockClientProxy.swift */; };
|
|
||||||
EE56238683BC3ECA9BA00684 /* GlobalSearchScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4D639E27D5882A6A71AECF /* GlobalSearchScreenViewModelTests.swift */; };
|
EE56238683BC3ECA9BA00684 /* GlobalSearchScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4D639E27D5882A6A71AECF /* GlobalSearchScreenViewModelTests.swift */; };
|
||||||
EE8491AD81F47DF3C192497B /* DecorationTimelineItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 184CF8C196BE143AE226628D /* DecorationTimelineItemProtocol.swift */; };
|
EE8491AD81F47DF3C192497B /* DecorationTimelineItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 184CF8C196BE143AE226628D /* DecorationTimelineItemProtocol.swift */; };
|
||||||
EE8A37E2A1A77DE5CF941632 /* StateRoomTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED983D4DCA5AFA6E1ED96099 /* StateRoomTimelineView.swift */; };
|
EE8A37E2A1A77DE5CF941632 /* StateRoomTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED983D4DCA5AFA6E1ED96099 /* StateRoomTimelineView.swift */; };
|
||||||
@@ -1332,7 +1332,6 @@
|
|||||||
3E6A9B9DFEE964962C179DE3 /* RoomAttachmentPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomAttachmentPicker.swift; sourceTree = "<group>"; };
|
3E6A9B9DFEE964962C179DE3 /* RoomAttachmentPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomAttachmentPicker.swift; sourceTree = "<group>"; };
|
||||||
3E93A1BE7D8A2EBCAD51EEB4 /* Array.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Array.swift; sourceTree = "<group>"; };
|
3E93A1BE7D8A2EBCAD51EEB4 /* Array.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Array.swift; sourceTree = "<group>"; };
|
||||||
3EF1AC723C2609C7705569CA /* MediaLoaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaLoaderTests.swift; sourceTree = "<group>"; };
|
3EF1AC723C2609C7705569CA /* MediaLoaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaLoaderTests.swift; sourceTree = "<group>"; };
|
||||||
3F40F48279322E504153AB0D /* MockClientProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockClientProxy.swift; sourceTree = "<group>"; };
|
|
||||||
3F684BDD23ECEADB3053BA5A /* DeveloperOptionsScreenUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperOptionsScreenUITests.swift; sourceTree = "<group>"; };
|
3F684BDD23ECEADB3053BA5A /* DeveloperOptionsScreenUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperOptionsScreenUITests.swift; sourceTree = "<group>"; };
|
||||||
3FFDA99C98BE05F43A92343B /* test_pdf.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = test_pdf.pdf; sourceTree = "<group>"; };
|
3FFDA99C98BE05F43A92343B /* test_pdf.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = test_pdf.pdf; sourceTree = "<group>"; };
|
||||||
40076C770A5FB83325252973 /* VoiceMessageMediaManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceMessageMediaManager.swift; sourceTree = "<group>"; };
|
40076C770A5FB83325252973 /* VoiceMessageMediaManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceMessageMediaManager.swift; sourceTree = "<group>"; };
|
||||||
@@ -1947,6 +1946,7 @@
|
|||||||
E2B1CC9AA154F4D5435BF60A /* Comparable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Comparable.swift; sourceTree = "<group>"; };
|
E2B1CC9AA154F4D5435BF60A /* Comparable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Comparable.swift; sourceTree = "<group>"; };
|
||||||
E2DCA495ED42D2463DDAA94D /* TimelineBubbleLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineBubbleLayout.swift; sourceTree = "<group>"; };
|
E2DCA495ED42D2463DDAA94D /* TimelineBubbleLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineBubbleLayout.swift; sourceTree = "<group>"; };
|
||||||
E2F27BAB69EB568369F1F6B3 /* OnboardingScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
E2F27BAB69EB568369F1F6B3 /* OnboardingScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
E2F96CCBEAAA7F2185BFA354 /* ClientProxyMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientProxyMock.swift; sourceTree = "<group>"; };
|
||||||
E3059CFA00C67D8787273B20 /* ServerSelectionScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionScreenViewModel.swift; sourceTree = "<group>"; };
|
E3059CFA00C67D8787273B20 /* ServerSelectionScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionScreenViewModel.swift; sourceTree = "<group>"; };
|
||||||
E36CB905A2B9EC2C92A2DA7C /* KeychainController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainController.swift; sourceTree = "<group>"; };
|
E36CB905A2B9EC2C92A2DA7C /* KeychainController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainController.swift; sourceTree = "<group>"; };
|
||||||
E3B97591B2D3D4D67553506D /* AnalyticsClientProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsClientProtocol.swift; sourceTree = "<group>"; };
|
E3B97591B2D3D4D67553506D /* AnalyticsClientProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsClientProtocol.swift; sourceTree = "<group>"; };
|
||||||
@@ -2581,6 +2581,7 @@
|
|||||||
children = (
|
children = (
|
||||||
69CB8242D69B7E4D0B32E18D /* AggregatedReactionMock.swift */,
|
69CB8242D69B7E4D0B32E18D /* AggregatedReactionMock.swift */,
|
||||||
62011D547772F3DF5D924823 /* ApplicationMock.swift */,
|
62011D547772F3DF5D924823 /* ApplicationMock.swift */,
|
||||||
|
E2F96CCBEAAA7F2185BFA354 /* ClientProxyMock.swift */,
|
||||||
382B50F7E379B3DBBD174364 /* NotificationSettingsProxyMock.swift */,
|
382B50F7E379B3DBBD174364 /* NotificationSettingsProxyMock.swift */,
|
||||||
D38391154120264910D19528 /* PollMock.swift */,
|
D38391154120264910D19528 /* PollMock.swift */,
|
||||||
36FD673E24FBFCFDF398716A /* RoomMemberProxyMock.swift */,
|
36FD673E24FBFCFDF398716A /* RoomMemberProxyMock.swift */,
|
||||||
@@ -3660,7 +3661,6 @@
|
|||||||
D09A267106B9585D3D0CFC0D /* ClientError.swift */,
|
D09A267106B9585D3D0CFC0D /* ClientError.swift */,
|
||||||
18F2958E6D247AE2516BEEE8 /* ClientProxy.swift */,
|
18F2958E6D247AE2516BEEE8 /* ClientProxy.swift */,
|
||||||
6033779EB37259F27F938937 /* ClientProxyProtocol.swift */,
|
6033779EB37259F27F938937 /* ClientProxyProtocol.swift */,
|
||||||
3F40F48279322E504153AB0D /* MockClientProxy.swift */,
|
|
||||||
);
|
);
|
||||||
path = Client;
|
path = Client;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -5653,6 +5653,7 @@
|
|||||||
6A0E7551E0D1793245F34CDD /* ClientError.swift in Sources */,
|
6A0E7551E0D1793245F34CDD /* ClientError.swift in Sources */,
|
||||||
520EEDAFBC778AB0B41F2F53 /* ClientMock.swift in Sources */,
|
520EEDAFBC778AB0B41F2F53 /* ClientMock.swift in Sources */,
|
||||||
1950A80CD198BED283DFC2CE /* ClientProxy.swift in Sources */,
|
1950A80CD198BED283DFC2CE /* ClientProxy.swift in Sources */,
|
||||||
|
DDFBDEE1DC32BDD5488F898C /* ClientProxyMock.swift in Sources */,
|
||||||
24BDDD09A90B8BFE3793F3AA /* ClientProxyProtocol.swift in Sources */,
|
24BDDD09A90B8BFE3793F3AA /* ClientProxyProtocol.swift in Sources */,
|
||||||
0C797CD650DFD2876BEC5173 /* CollapsibleReactionLayout.swift in Sources */,
|
0C797CD650DFD2876BEC5173 /* CollapsibleReactionLayout.swift in Sources */,
|
||||||
9FAF6DA7E8E85C9699757764 /* CollapsibleRoomTimelineView.swift in Sources */,
|
9FAF6DA7E8E85C9699757764 /* CollapsibleRoomTimelineView.swift in Sources */,
|
||||||
@@ -5847,7 +5848,6 @@
|
|||||||
C13128AAA787A4C2CBE4EE82 /* MessageForwardingScreenViewModelProtocol.swift in Sources */,
|
C13128AAA787A4C2CBE4EE82 /* MessageForwardingScreenViewModelProtocol.swift in Sources */,
|
||||||
C97325EFDCCEE457432A9E82 /* MessageText.swift in Sources */,
|
C97325EFDCCEE457432A9E82 /* MessageText.swift in Sources */,
|
||||||
152AE2B8650FB23AFD2E28B9 /* MockAuthenticationServiceProxy.swift in Sources */,
|
152AE2B8650FB23AFD2E28B9 /* MockAuthenticationServiceProxy.swift in Sources */,
|
||||||
EE4F5601356228FF72FC56B6 /* MockClientProxy.swift in Sources */,
|
|
||||||
B659E3A49889E749E3239EA7 /* MockMediaProvider.swift in Sources */,
|
B659E3A49889E749E3239EA7 /* MockMediaProvider.swift in Sources */,
|
||||||
2352C541AF857241489756FF /* MockRoomSummaryProvider.swift in Sources */,
|
2352C541AF857241489756FF /* MockRoomSummaryProvider.swift in Sources */,
|
||||||
09C83DDDB07C28364F325209 /* MockRoomTimelineController.swift in Sources */,
|
09C83DDDB07C28364F325209 /* MockRoomTimelineController.swift in Sources */,
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2024 New Vector Ltd
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Combine
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct ClientProxyMockConfiguration {
|
||||||
|
let userID: String
|
||||||
|
var deviceID: String?
|
||||||
|
var roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ClientProxyMock {
|
||||||
|
convenience init(_ configuration: ClientProxyMockConfiguration) {
|
||||||
|
self.init()
|
||||||
|
|
||||||
|
userID = configuration.userID
|
||||||
|
deviceID = configuration.deviceID
|
||||||
|
|
||||||
|
homeserver = ""
|
||||||
|
|
||||||
|
roomSummaryProvider = configuration.roomSummaryProvider
|
||||||
|
alternateRoomSummaryProvider = MockRoomSummaryProvider()
|
||||||
|
inviteSummaryProvider = MockRoomSummaryProvider()
|
||||||
|
|
||||||
|
actionsPublisher = PassthroughSubject<ClientProxyAction, Never>().eraseToAnyPublisher()
|
||||||
|
loadingStatePublisher = CurrentValuePublisher<ClientProxyLoadingState, Never>(.notLoading)
|
||||||
|
|
||||||
|
userAvatarURLPublisher = CurrentValueSubject<URL?, Never>(nil).asCurrentValuePublisher()
|
||||||
|
|
||||||
|
userDisplayNamePublisher = CurrentValueSubject<String?, Never>("User display name").asCurrentValuePublisher()
|
||||||
|
|
||||||
|
ignoredUsersPublisher = CurrentValueSubject<[String]?, Never>([RoomMemberProxyMock].allMembers.map(\.userID)).asCurrentValuePublisher()
|
||||||
|
|
||||||
|
notificationSettings = NotificationSettingsProxyMock(with: .init())
|
||||||
|
|
||||||
|
isOnlyDeviceLeftReturnValue = .success(false)
|
||||||
|
accountURLActionReturnValue = "https://matrix.org/account"
|
||||||
|
directRoomForUserIDReturnValue = .failure(.failedRetrievingDirectRoom)
|
||||||
|
createDirectRoomWithExpectedRoomNameReturnValue = .failure(.failedCreatingRoom)
|
||||||
|
createRoomNameTopicIsRoomPrivateUserIDsAvatarURLReturnValue = .failure(.failedCreatingRoom)
|
||||||
|
uploadMediaReturnValue = .failure(.failedUploadingMedia(.unknown))
|
||||||
|
loadUserDisplayNameReturnValue = .failure(.failedRetrievingUserDisplayName)
|
||||||
|
setUserDisplayNameReturnValue = .failure(.failedSettingUserDisplayName)
|
||||||
|
loadUserAvatarURLReturnValue = .failure(.failedRetrievingUserAvatarURL)
|
||||||
|
setUserAvatarMediaReturnValue = .failure(.failedSettingUserAvatar)
|
||||||
|
removeUserAvatarReturnValue = .failure(.failedSettingUserAvatar)
|
||||||
|
logoutReturnValue = nil
|
||||||
|
searchUsersSearchTermLimitReturnValue = .success(.init(results: [], limited: false))
|
||||||
|
profileForReturnValue = .success(.init(userID: "@a:b.com", displayName: "Some user"))
|
||||||
|
sessionVerificationControllerProxyReturnValue = .failure(.failedRetrievingSessionVerificationController)
|
||||||
|
ignoreUserReturnValue = .failure(.failedIgnoringUser)
|
||||||
|
unignoreUserReturnValue = .failure(.failedUnignoringUser)
|
||||||
|
|
||||||
|
loadMediaContentForSourceThrowableError = ClientProxyError.failedLoadingMedia
|
||||||
|
loadMediaThumbnailForSourceWidthHeightThrowableError = ClientProxyError.failedLoadingMedia
|
||||||
|
loadMediaFileForSourceBodyThrowableError = ClientProxyError.failedLoadingMedia
|
||||||
|
|
||||||
|
secureBackupController = {
|
||||||
|
let secureBackupController = SecureBackupControllerMock()
|
||||||
|
secureBackupController.underlyingRecoveryState = .init(CurrentValueSubject<SecureBackupRecoveryState, Never>(.enabled))
|
||||||
|
secureBackupController.underlyingKeyBackupState = .init(CurrentValueSubject<SecureBackupKeyBackupState, Never>(.enabled))
|
||||||
|
return secureBackupController
|
||||||
|
}()
|
||||||
|
|
||||||
|
roomForIdentifierClosure = { [weak self] identifier in
|
||||||
|
guard let room = self?.roomSummaryProvider?.roomListPublisher.value.first(where: { $0.id == identifier }) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
switch room {
|
||||||
|
case .empty:
|
||||||
|
return await RoomProxyMock(with: .init(name: "Empty room"))
|
||||||
|
case .filled(let details), .invalidated(let details):
|
||||||
|
return await RoomProxyMock(with: .init(name: details.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -716,6 +716,534 @@ class BugReportServiceMock: BugReportServiceProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class ClientProxyMock: ClientProxyProtocol {
|
||||||
|
var actionsPublisher: AnyPublisher<ClientProxyAction, Never> {
|
||||||
|
get { return underlyingActionsPublisher }
|
||||||
|
set(value) { underlyingActionsPublisher = value }
|
||||||
|
}
|
||||||
|
var underlyingActionsPublisher: AnyPublisher<ClientProxyAction, Never>!
|
||||||
|
var loadingStatePublisher: CurrentValuePublisher<ClientProxyLoadingState, Never> {
|
||||||
|
get { return underlyingLoadingStatePublisher }
|
||||||
|
set(value) { underlyingLoadingStatePublisher = value }
|
||||||
|
}
|
||||||
|
var underlyingLoadingStatePublisher: CurrentValuePublisher<ClientProxyLoadingState, Never>!
|
||||||
|
var userID: String {
|
||||||
|
get { return underlyingUserID }
|
||||||
|
set(value) { underlyingUserID = value }
|
||||||
|
}
|
||||||
|
var underlyingUserID: String!
|
||||||
|
var deviceID: String?
|
||||||
|
var homeserver: String {
|
||||||
|
get { return underlyingHomeserver }
|
||||||
|
set(value) { underlyingHomeserver = value }
|
||||||
|
}
|
||||||
|
var underlyingHomeserver: String!
|
||||||
|
var userDisplayNamePublisher: CurrentValuePublisher<String?, Never> {
|
||||||
|
get { return underlyingUserDisplayNamePublisher }
|
||||||
|
set(value) { underlyingUserDisplayNamePublisher = value }
|
||||||
|
}
|
||||||
|
var underlyingUserDisplayNamePublisher: CurrentValuePublisher<String?, Never>!
|
||||||
|
var userAvatarURLPublisher: CurrentValuePublisher<URL?, Never> {
|
||||||
|
get { return underlyingUserAvatarURLPublisher }
|
||||||
|
set(value) { underlyingUserAvatarURLPublisher = value }
|
||||||
|
}
|
||||||
|
var underlyingUserAvatarURLPublisher: CurrentValuePublisher<URL?, Never>!
|
||||||
|
var ignoredUsersPublisher: CurrentValuePublisher<[String]?, Never> {
|
||||||
|
get { return underlyingIgnoredUsersPublisher }
|
||||||
|
set(value) { underlyingIgnoredUsersPublisher = value }
|
||||||
|
}
|
||||||
|
var underlyingIgnoredUsersPublisher: CurrentValuePublisher<[String]?, Never>!
|
||||||
|
var pusherNotificationClientIdentifier: String?
|
||||||
|
var roomSummaryProvider: RoomSummaryProviderProtocol?
|
||||||
|
var alternateRoomSummaryProvider: RoomSummaryProviderProtocol?
|
||||||
|
var inviteSummaryProvider: RoomSummaryProviderProtocol?
|
||||||
|
var notificationSettings: NotificationSettingsProxyProtocol {
|
||||||
|
get { return underlyingNotificationSettings }
|
||||||
|
set(value) { underlyingNotificationSettings = value }
|
||||||
|
}
|
||||||
|
var underlyingNotificationSettings: NotificationSettingsProxyProtocol!
|
||||||
|
var secureBackupController: SecureBackupControllerProtocol {
|
||||||
|
get { return underlyingSecureBackupController }
|
||||||
|
set(value) { underlyingSecureBackupController = value }
|
||||||
|
}
|
||||||
|
var underlyingSecureBackupController: SecureBackupControllerProtocol!
|
||||||
|
|
||||||
|
//MARK: - isOnlyDeviceLeft
|
||||||
|
|
||||||
|
var isOnlyDeviceLeftCallsCount = 0
|
||||||
|
var isOnlyDeviceLeftCalled: Bool {
|
||||||
|
return isOnlyDeviceLeftCallsCount > 0
|
||||||
|
}
|
||||||
|
var isOnlyDeviceLeftReturnValue: Result<Bool, ClientProxyError>!
|
||||||
|
var isOnlyDeviceLeftClosure: (() async -> Result<Bool, ClientProxyError>)?
|
||||||
|
|
||||||
|
func isOnlyDeviceLeft() async -> Result<Bool, ClientProxyError> {
|
||||||
|
isOnlyDeviceLeftCallsCount += 1
|
||||||
|
if let isOnlyDeviceLeftClosure = isOnlyDeviceLeftClosure {
|
||||||
|
return await isOnlyDeviceLeftClosure()
|
||||||
|
} else {
|
||||||
|
return isOnlyDeviceLeftReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - startSync
|
||||||
|
|
||||||
|
var startSyncCallsCount = 0
|
||||||
|
var startSyncCalled: Bool {
|
||||||
|
return startSyncCallsCount > 0
|
||||||
|
}
|
||||||
|
var startSyncClosure: (() -> Void)?
|
||||||
|
|
||||||
|
func startSync() {
|
||||||
|
startSyncCallsCount += 1
|
||||||
|
startSyncClosure?()
|
||||||
|
}
|
||||||
|
//MARK: - stopSync
|
||||||
|
|
||||||
|
var stopSyncCallsCount = 0
|
||||||
|
var stopSyncCalled: Bool {
|
||||||
|
return stopSyncCallsCount > 0
|
||||||
|
}
|
||||||
|
var stopSyncClosure: (() -> Void)?
|
||||||
|
|
||||||
|
func stopSync() {
|
||||||
|
stopSyncCallsCount += 1
|
||||||
|
stopSyncClosure?()
|
||||||
|
}
|
||||||
|
//MARK: - accountURL
|
||||||
|
|
||||||
|
var accountURLActionCallsCount = 0
|
||||||
|
var accountURLActionCalled: Bool {
|
||||||
|
return accountURLActionCallsCount > 0
|
||||||
|
}
|
||||||
|
var accountURLActionReceivedAction: AccountManagementAction?
|
||||||
|
var accountURLActionReceivedInvocations: [AccountManagementAction] = []
|
||||||
|
var accountURLActionReturnValue: URL?
|
||||||
|
var accountURLActionClosure: ((AccountManagementAction) -> URL?)?
|
||||||
|
|
||||||
|
func accountURL(action: AccountManagementAction) -> URL? {
|
||||||
|
accountURLActionCallsCount += 1
|
||||||
|
accountURLActionReceivedAction = action
|
||||||
|
accountURLActionReceivedInvocations.append(action)
|
||||||
|
if let accountURLActionClosure = accountURLActionClosure {
|
||||||
|
return accountURLActionClosure(action)
|
||||||
|
} else {
|
||||||
|
return accountURLActionReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - directRoomForUserID
|
||||||
|
|
||||||
|
var directRoomForUserIDCallsCount = 0
|
||||||
|
var directRoomForUserIDCalled: Bool {
|
||||||
|
return directRoomForUserIDCallsCount > 0
|
||||||
|
}
|
||||||
|
var directRoomForUserIDReceivedUserID: String?
|
||||||
|
var directRoomForUserIDReceivedInvocations: [String] = []
|
||||||
|
var directRoomForUserIDReturnValue: Result<String?, ClientProxyError>!
|
||||||
|
var directRoomForUserIDClosure: ((String) async -> Result<String?, ClientProxyError>)?
|
||||||
|
|
||||||
|
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError> {
|
||||||
|
directRoomForUserIDCallsCount += 1
|
||||||
|
directRoomForUserIDReceivedUserID = userID
|
||||||
|
directRoomForUserIDReceivedInvocations.append(userID)
|
||||||
|
if let directRoomForUserIDClosure = directRoomForUserIDClosure {
|
||||||
|
return await directRoomForUserIDClosure(userID)
|
||||||
|
} else {
|
||||||
|
return directRoomForUserIDReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - createDirectRoom
|
||||||
|
|
||||||
|
var createDirectRoomWithExpectedRoomNameCallsCount = 0
|
||||||
|
var createDirectRoomWithExpectedRoomNameCalled: Bool {
|
||||||
|
return createDirectRoomWithExpectedRoomNameCallsCount > 0
|
||||||
|
}
|
||||||
|
var createDirectRoomWithExpectedRoomNameReceivedArguments: (userID: String, expectedRoomName: String?)?
|
||||||
|
var createDirectRoomWithExpectedRoomNameReceivedInvocations: [(userID: String, expectedRoomName: String?)] = []
|
||||||
|
var createDirectRoomWithExpectedRoomNameReturnValue: Result<String, ClientProxyError>!
|
||||||
|
var createDirectRoomWithExpectedRoomNameClosure: ((String, String?) async -> Result<String, ClientProxyError>)?
|
||||||
|
|
||||||
|
func createDirectRoom(with userID: String, expectedRoomName: String?) async -> Result<String, ClientProxyError> {
|
||||||
|
createDirectRoomWithExpectedRoomNameCallsCount += 1
|
||||||
|
createDirectRoomWithExpectedRoomNameReceivedArguments = (userID: userID, expectedRoomName: expectedRoomName)
|
||||||
|
createDirectRoomWithExpectedRoomNameReceivedInvocations.append((userID: userID, expectedRoomName: expectedRoomName))
|
||||||
|
if let createDirectRoomWithExpectedRoomNameClosure = createDirectRoomWithExpectedRoomNameClosure {
|
||||||
|
return await createDirectRoomWithExpectedRoomNameClosure(userID, expectedRoomName)
|
||||||
|
} else {
|
||||||
|
return createDirectRoomWithExpectedRoomNameReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - createRoom
|
||||||
|
|
||||||
|
var createRoomNameTopicIsRoomPrivateUserIDsAvatarURLCallsCount = 0
|
||||||
|
var createRoomNameTopicIsRoomPrivateUserIDsAvatarURLCalled: Bool {
|
||||||
|
return createRoomNameTopicIsRoomPrivateUserIDsAvatarURLCallsCount > 0
|
||||||
|
}
|
||||||
|
var createRoomNameTopicIsRoomPrivateUserIDsAvatarURLReceivedArguments: (name: String, topic: String?, isRoomPrivate: Bool, userIDs: [String], avatarURL: URL?)?
|
||||||
|
var createRoomNameTopicIsRoomPrivateUserIDsAvatarURLReceivedInvocations: [(name: String, topic: String?, isRoomPrivate: Bool, userIDs: [String], avatarURL: URL?)] = []
|
||||||
|
var createRoomNameTopicIsRoomPrivateUserIDsAvatarURLReturnValue: Result<String, ClientProxyError>!
|
||||||
|
var createRoomNameTopicIsRoomPrivateUserIDsAvatarURLClosure: ((String, String?, Bool, [String], URL?) async -> Result<String, ClientProxyError>)?
|
||||||
|
|
||||||
|
func createRoom(name: String, topic: String?, isRoomPrivate: Bool, userIDs: [String], avatarURL: URL?) async -> Result<String, ClientProxyError> {
|
||||||
|
createRoomNameTopicIsRoomPrivateUserIDsAvatarURLCallsCount += 1
|
||||||
|
createRoomNameTopicIsRoomPrivateUserIDsAvatarURLReceivedArguments = (name: name, topic: topic, isRoomPrivate: isRoomPrivate, userIDs: userIDs, avatarURL: avatarURL)
|
||||||
|
createRoomNameTopicIsRoomPrivateUserIDsAvatarURLReceivedInvocations.append((name: name, topic: topic, isRoomPrivate: isRoomPrivate, userIDs: userIDs, avatarURL: avatarURL))
|
||||||
|
if let createRoomNameTopicIsRoomPrivateUserIDsAvatarURLClosure = createRoomNameTopicIsRoomPrivateUserIDsAvatarURLClosure {
|
||||||
|
return await createRoomNameTopicIsRoomPrivateUserIDsAvatarURLClosure(name, topic, isRoomPrivate, userIDs, avatarURL)
|
||||||
|
} else {
|
||||||
|
return createRoomNameTopicIsRoomPrivateUserIDsAvatarURLReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - uploadMedia
|
||||||
|
|
||||||
|
var uploadMediaCallsCount = 0
|
||||||
|
var uploadMediaCalled: Bool {
|
||||||
|
return uploadMediaCallsCount > 0
|
||||||
|
}
|
||||||
|
var uploadMediaReceivedMedia: MediaInfo?
|
||||||
|
var uploadMediaReceivedInvocations: [MediaInfo] = []
|
||||||
|
var uploadMediaReturnValue: Result<String, ClientProxyError>!
|
||||||
|
var uploadMediaClosure: ((MediaInfo) async -> Result<String, ClientProxyError>)?
|
||||||
|
|
||||||
|
func uploadMedia(_ media: MediaInfo) async -> Result<String, ClientProxyError> {
|
||||||
|
uploadMediaCallsCount += 1
|
||||||
|
uploadMediaReceivedMedia = media
|
||||||
|
uploadMediaReceivedInvocations.append(media)
|
||||||
|
if let uploadMediaClosure = uploadMediaClosure {
|
||||||
|
return await uploadMediaClosure(media)
|
||||||
|
} else {
|
||||||
|
return uploadMediaReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - roomForIdentifier
|
||||||
|
|
||||||
|
var roomForIdentifierCallsCount = 0
|
||||||
|
var roomForIdentifierCalled: Bool {
|
||||||
|
return roomForIdentifierCallsCount > 0
|
||||||
|
}
|
||||||
|
var roomForIdentifierReceivedIdentifier: String?
|
||||||
|
var roomForIdentifierReceivedInvocations: [String] = []
|
||||||
|
var roomForIdentifierReturnValue: RoomProxyProtocol?
|
||||||
|
var roomForIdentifierClosure: ((String) async -> RoomProxyProtocol?)?
|
||||||
|
|
||||||
|
func roomForIdentifier(_ identifier: String) async -> RoomProxyProtocol? {
|
||||||
|
roomForIdentifierCallsCount += 1
|
||||||
|
roomForIdentifierReceivedIdentifier = identifier
|
||||||
|
roomForIdentifierReceivedInvocations.append(identifier)
|
||||||
|
if let roomForIdentifierClosure = roomForIdentifierClosure {
|
||||||
|
return await roomForIdentifierClosure(identifier)
|
||||||
|
} else {
|
||||||
|
return roomForIdentifierReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - loadUserDisplayName
|
||||||
|
|
||||||
|
var loadUserDisplayNameCallsCount = 0
|
||||||
|
var loadUserDisplayNameCalled: Bool {
|
||||||
|
return loadUserDisplayNameCallsCount > 0
|
||||||
|
}
|
||||||
|
var loadUserDisplayNameReturnValue: Result<Void, ClientProxyError>!
|
||||||
|
var loadUserDisplayNameClosure: (() async -> Result<Void, ClientProxyError>)?
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
func loadUserDisplayName() async -> Result<Void, ClientProxyError> {
|
||||||
|
loadUserDisplayNameCallsCount += 1
|
||||||
|
if let loadUserDisplayNameClosure = loadUserDisplayNameClosure {
|
||||||
|
return await loadUserDisplayNameClosure()
|
||||||
|
} else {
|
||||||
|
return loadUserDisplayNameReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - setUserDisplayName
|
||||||
|
|
||||||
|
var setUserDisplayNameCallsCount = 0
|
||||||
|
var setUserDisplayNameCalled: Bool {
|
||||||
|
return setUserDisplayNameCallsCount > 0
|
||||||
|
}
|
||||||
|
var setUserDisplayNameReceivedName: String?
|
||||||
|
var setUserDisplayNameReceivedInvocations: [String] = []
|
||||||
|
var setUserDisplayNameReturnValue: Result<Void, ClientProxyError>!
|
||||||
|
var setUserDisplayNameClosure: ((String) async -> Result<Void, ClientProxyError>)?
|
||||||
|
|
||||||
|
func setUserDisplayName(_ name: String) async -> Result<Void, ClientProxyError> {
|
||||||
|
setUserDisplayNameCallsCount += 1
|
||||||
|
setUserDisplayNameReceivedName = name
|
||||||
|
setUserDisplayNameReceivedInvocations.append(name)
|
||||||
|
if let setUserDisplayNameClosure = setUserDisplayNameClosure {
|
||||||
|
return await setUserDisplayNameClosure(name)
|
||||||
|
} else {
|
||||||
|
return setUserDisplayNameReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - loadUserAvatarURL
|
||||||
|
|
||||||
|
var loadUserAvatarURLCallsCount = 0
|
||||||
|
var loadUserAvatarURLCalled: Bool {
|
||||||
|
return loadUserAvatarURLCallsCount > 0
|
||||||
|
}
|
||||||
|
var loadUserAvatarURLReturnValue: Result<Void, ClientProxyError>!
|
||||||
|
var loadUserAvatarURLClosure: (() async -> Result<Void, ClientProxyError>)?
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
func loadUserAvatarURL() async -> Result<Void, ClientProxyError> {
|
||||||
|
loadUserAvatarURLCallsCount += 1
|
||||||
|
if let loadUserAvatarURLClosure = loadUserAvatarURLClosure {
|
||||||
|
return await loadUserAvatarURLClosure()
|
||||||
|
} else {
|
||||||
|
return loadUserAvatarURLReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - setUserAvatar
|
||||||
|
|
||||||
|
var setUserAvatarMediaCallsCount = 0
|
||||||
|
var setUserAvatarMediaCalled: Bool {
|
||||||
|
return setUserAvatarMediaCallsCount > 0
|
||||||
|
}
|
||||||
|
var setUserAvatarMediaReceivedMedia: MediaInfo?
|
||||||
|
var setUserAvatarMediaReceivedInvocations: [MediaInfo] = []
|
||||||
|
var setUserAvatarMediaReturnValue: Result<Void, ClientProxyError>!
|
||||||
|
var setUserAvatarMediaClosure: ((MediaInfo) async -> Result<Void, ClientProxyError>)?
|
||||||
|
|
||||||
|
func setUserAvatar(media: MediaInfo) async -> Result<Void, ClientProxyError> {
|
||||||
|
setUserAvatarMediaCallsCount += 1
|
||||||
|
setUserAvatarMediaReceivedMedia = media
|
||||||
|
setUserAvatarMediaReceivedInvocations.append(media)
|
||||||
|
if let setUserAvatarMediaClosure = setUserAvatarMediaClosure {
|
||||||
|
return await setUserAvatarMediaClosure(media)
|
||||||
|
} else {
|
||||||
|
return setUserAvatarMediaReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - removeUserAvatar
|
||||||
|
|
||||||
|
var removeUserAvatarCallsCount = 0
|
||||||
|
var removeUserAvatarCalled: Bool {
|
||||||
|
return removeUserAvatarCallsCount > 0
|
||||||
|
}
|
||||||
|
var removeUserAvatarReturnValue: Result<Void, ClientProxyError>!
|
||||||
|
var removeUserAvatarClosure: (() async -> Result<Void, ClientProxyError>)?
|
||||||
|
|
||||||
|
func removeUserAvatar() async -> Result<Void, ClientProxyError> {
|
||||||
|
removeUserAvatarCallsCount += 1
|
||||||
|
if let removeUserAvatarClosure = removeUserAvatarClosure {
|
||||||
|
return await removeUserAvatarClosure()
|
||||||
|
} else {
|
||||||
|
return removeUserAvatarReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - sessionVerificationControllerProxy
|
||||||
|
|
||||||
|
var sessionVerificationControllerProxyCallsCount = 0
|
||||||
|
var sessionVerificationControllerProxyCalled: Bool {
|
||||||
|
return sessionVerificationControllerProxyCallsCount > 0
|
||||||
|
}
|
||||||
|
var sessionVerificationControllerProxyReturnValue: Result<SessionVerificationControllerProxyProtocol, ClientProxyError>!
|
||||||
|
var sessionVerificationControllerProxyClosure: (() async -> Result<SessionVerificationControllerProxyProtocol, ClientProxyError>)?
|
||||||
|
|
||||||
|
func sessionVerificationControllerProxy() async -> Result<SessionVerificationControllerProxyProtocol, ClientProxyError> {
|
||||||
|
sessionVerificationControllerProxyCallsCount += 1
|
||||||
|
if let sessionVerificationControllerProxyClosure = sessionVerificationControllerProxyClosure {
|
||||||
|
return await sessionVerificationControllerProxyClosure()
|
||||||
|
} else {
|
||||||
|
return sessionVerificationControllerProxyReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - logout
|
||||||
|
|
||||||
|
var logoutCallsCount = 0
|
||||||
|
var logoutCalled: Bool {
|
||||||
|
return logoutCallsCount > 0
|
||||||
|
}
|
||||||
|
var logoutReturnValue: URL?
|
||||||
|
var logoutClosure: (() async -> URL?)?
|
||||||
|
|
||||||
|
func logout() async -> URL? {
|
||||||
|
logoutCallsCount += 1
|
||||||
|
if let logoutClosure = logoutClosure {
|
||||||
|
return await logoutClosure()
|
||||||
|
} else {
|
||||||
|
return logoutReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - setPusher
|
||||||
|
|
||||||
|
var setPusherWithThrowableError: Error?
|
||||||
|
var setPusherWithCallsCount = 0
|
||||||
|
var setPusherWithCalled: Bool {
|
||||||
|
return setPusherWithCallsCount > 0
|
||||||
|
}
|
||||||
|
var setPusherWithReceivedConfiguration: PusherConfiguration?
|
||||||
|
var setPusherWithReceivedInvocations: [PusherConfiguration] = []
|
||||||
|
var setPusherWithClosure: ((PusherConfiguration) async throws -> Void)?
|
||||||
|
|
||||||
|
func setPusher(with configuration: PusherConfiguration) async throws {
|
||||||
|
if let error = setPusherWithThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
setPusherWithCallsCount += 1
|
||||||
|
setPusherWithReceivedConfiguration = configuration
|
||||||
|
setPusherWithReceivedInvocations.append(configuration)
|
||||||
|
try await setPusherWithClosure?(configuration)
|
||||||
|
}
|
||||||
|
//MARK: - searchUsers
|
||||||
|
|
||||||
|
var searchUsersSearchTermLimitCallsCount = 0
|
||||||
|
var searchUsersSearchTermLimitCalled: Bool {
|
||||||
|
return searchUsersSearchTermLimitCallsCount > 0
|
||||||
|
}
|
||||||
|
var searchUsersSearchTermLimitReceivedArguments: (searchTerm: String, limit: UInt)?
|
||||||
|
var searchUsersSearchTermLimitReceivedInvocations: [(searchTerm: String, limit: UInt)] = []
|
||||||
|
var searchUsersSearchTermLimitReturnValue: Result<SearchUsersResultsProxy, ClientProxyError>!
|
||||||
|
var searchUsersSearchTermLimitClosure: ((String, UInt) async -> Result<SearchUsersResultsProxy, ClientProxyError>)?
|
||||||
|
|
||||||
|
func searchUsers(searchTerm: String, limit: UInt) async -> Result<SearchUsersResultsProxy, ClientProxyError> {
|
||||||
|
searchUsersSearchTermLimitCallsCount += 1
|
||||||
|
searchUsersSearchTermLimitReceivedArguments = (searchTerm: searchTerm, limit: limit)
|
||||||
|
searchUsersSearchTermLimitReceivedInvocations.append((searchTerm: searchTerm, limit: limit))
|
||||||
|
if let searchUsersSearchTermLimitClosure = searchUsersSearchTermLimitClosure {
|
||||||
|
return await searchUsersSearchTermLimitClosure(searchTerm, limit)
|
||||||
|
} else {
|
||||||
|
return searchUsersSearchTermLimitReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - profile
|
||||||
|
|
||||||
|
var profileForCallsCount = 0
|
||||||
|
var profileForCalled: Bool {
|
||||||
|
return profileForCallsCount > 0
|
||||||
|
}
|
||||||
|
var profileForReceivedUserID: String?
|
||||||
|
var profileForReceivedInvocations: [String] = []
|
||||||
|
var profileForReturnValue: Result<UserProfileProxy, ClientProxyError>!
|
||||||
|
var profileForClosure: ((String) async -> Result<UserProfileProxy, ClientProxyError>)?
|
||||||
|
|
||||||
|
func profile(for userID: String) async -> Result<UserProfileProxy, ClientProxyError> {
|
||||||
|
profileForCallsCount += 1
|
||||||
|
profileForReceivedUserID = userID
|
||||||
|
profileForReceivedInvocations.append(userID)
|
||||||
|
if let profileForClosure = profileForClosure {
|
||||||
|
return await profileForClosure(userID)
|
||||||
|
} else {
|
||||||
|
return profileForReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - ignoreUser
|
||||||
|
|
||||||
|
var ignoreUserCallsCount = 0
|
||||||
|
var ignoreUserCalled: Bool {
|
||||||
|
return ignoreUserCallsCount > 0
|
||||||
|
}
|
||||||
|
var ignoreUserReceivedUserID: String?
|
||||||
|
var ignoreUserReceivedInvocations: [String] = []
|
||||||
|
var ignoreUserReturnValue: Result<Void, ClientProxyError>!
|
||||||
|
var ignoreUserClosure: ((String) async -> Result<Void, ClientProxyError>)?
|
||||||
|
|
||||||
|
func ignoreUser(_ userID: String) async -> Result<Void, ClientProxyError> {
|
||||||
|
ignoreUserCallsCount += 1
|
||||||
|
ignoreUserReceivedUserID = userID
|
||||||
|
ignoreUserReceivedInvocations.append(userID)
|
||||||
|
if let ignoreUserClosure = ignoreUserClosure {
|
||||||
|
return await ignoreUserClosure(userID)
|
||||||
|
} else {
|
||||||
|
return ignoreUserReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - unignoreUser
|
||||||
|
|
||||||
|
var unignoreUserCallsCount = 0
|
||||||
|
var unignoreUserCalled: Bool {
|
||||||
|
return unignoreUserCallsCount > 0
|
||||||
|
}
|
||||||
|
var unignoreUserReceivedUserID: String?
|
||||||
|
var unignoreUserReceivedInvocations: [String] = []
|
||||||
|
var unignoreUserReturnValue: Result<Void, ClientProxyError>!
|
||||||
|
var unignoreUserClosure: ((String) async -> Result<Void, ClientProxyError>)?
|
||||||
|
|
||||||
|
func unignoreUser(_ userID: String) async -> Result<Void, ClientProxyError> {
|
||||||
|
unignoreUserCallsCount += 1
|
||||||
|
unignoreUserReceivedUserID = userID
|
||||||
|
unignoreUserReceivedInvocations.append(userID)
|
||||||
|
if let unignoreUserClosure = unignoreUserClosure {
|
||||||
|
return await unignoreUserClosure(userID)
|
||||||
|
} else {
|
||||||
|
return unignoreUserReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - loadMediaContentForSource
|
||||||
|
|
||||||
|
var loadMediaContentForSourceThrowableError: Error?
|
||||||
|
var loadMediaContentForSourceCallsCount = 0
|
||||||
|
var loadMediaContentForSourceCalled: Bool {
|
||||||
|
return loadMediaContentForSourceCallsCount > 0
|
||||||
|
}
|
||||||
|
var loadMediaContentForSourceReceivedSource: MediaSourceProxy?
|
||||||
|
var loadMediaContentForSourceReceivedInvocations: [MediaSourceProxy] = []
|
||||||
|
var loadMediaContentForSourceReturnValue: Data!
|
||||||
|
var loadMediaContentForSourceClosure: ((MediaSourceProxy) async throws -> Data)?
|
||||||
|
|
||||||
|
func loadMediaContentForSource(_ source: MediaSourceProxy) async throws -> Data {
|
||||||
|
if let error = loadMediaContentForSourceThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
loadMediaContentForSourceCallsCount += 1
|
||||||
|
loadMediaContentForSourceReceivedSource = source
|
||||||
|
loadMediaContentForSourceReceivedInvocations.append(source)
|
||||||
|
if let loadMediaContentForSourceClosure = loadMediaContentForSourceClosure {
|
||||||
|
return try await loadMediaContentForSourceClosure(source)
|
||||||
|
} else {
|
||||||
|
return loadMediaContentForSourceReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - loadMediaThumbnailForSource
|
||||||
|
|
||||||
|
var loadMediaThumbnailForSourceWidthHeightThrowableError: Error?
|
||||||
|
var loadMediaThumbnailForSourceWidthHeightCallsCount = 0
|
||||||
|
var loadMediaThumbnailForSourceWidthHeightCalled: Bool {
|
||||||
|
return loadMediaThumbnailForSourceWidthHeightCallsCount > 0
|
||||||
|
}
|
||||||
|
var loadMediaThumbnailForSourceWidthHeightReceivedArguments: (source: MediaSourceProxy, width: UInt, height: UInt)?
|
||||||
|
var loadMediaThumbnailForSourceWidthHeightReceivedInvocations: [(source: MediaSourceProxy, width: UInt, height: UInt)] = []
|
||||||
|
var loadMediaThumbnailForSourceWidthHeightReturnValue: Data!
|
||||||
|
var loadMediaThumbnailForSourceWidthHeightClosure: ((MediaSourceProxy, UInt, UInt) async throws -> Data)?
|
||||||
|
|
||||||
|
func loadMediaThumbnailForSource(_ source: MediaSourceProxy, width: UInt, height: UInt) async throws -> Data {
|
||||||
|
if let error = loadMediaThumbnailForSourceWidthHeightThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
loadMediaThumbnailForSourceWidthHeightCallsCount += 1
|
||||||
|
loadMediaThumbnailForSourceWidthHeightReceivedArguments = (source: source, width: width, height: height)
|
||||||
|
loadMediaThumbnailForSourceWidthHeightReceivedInvocations.append((source: source, width: width, height: height))
|
||||||
|
if let loadMediaThumbnailForSourceWidthHeightClosure = loadMediaThumbnailForSourceWidthHeightClosure {
|
||||||
|
return try await loadMediaThumbnailForSourceWidthHeightClosure(source, width, height)
|
||||||
|
} else {
|
||||||
|
return loadMediaThumbnailForSourceWidthHeightReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//MARK: - loadMediaFileForSource
|
||||||
|
|
||||||
|
var loadMediaFileForSourceBodyThrowableError: Error?
|
||||||
|
var loadMediaFileForSourceBodyCallsCount = 0
|
||||||
|
var loadMediaFileForSourceBodyCalled: Bool {
|
||||||
|
return loadMediaFileForSourceBodyCallsCount > 0
|
||||||
|
}
|
||||||
|
var loadMediaFileForSourceBodyReceivedArguments: (source: MediaSourceProxy, body: String?)?
|
||||||
|
var loadMediaFileForSourceBodyReceivedInvocations: [(source: MediaSourceProxy, body: String?)] = []
|
||||||
|
var loadMediaFileForSourceBodyReturnValue: MediaFileHandleProxy!
|
||||||
|
var loadMediaFileForSourceBodyClosure: ((MediaSourceProxy, String?) async throws -> MediaFileHandleProxy)?
|
||||||
|
|
||||||
|
func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy {
|
||||||
|
if let error = loadMediaFileForSourceBodyThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
loadMediaFileForSourceBodyCallsCount += 1
|
||||||
|
loadMediaFileForSourceBodyReceivedArguments = (source: source, body: body)
|
||||||
|
loadMediaFileForSourceBodyReceivedInvocations.append((source: source, body: body))
|
||||||
|
if let loadMediaFileForSourceBodyClosure = loadMediaFileForSourceBodyClosure {
|
||||||
|
return try await loadMediaFileForSourceBodyClosure(source, body)
|
||||||
|
} else {
|
||||||
|
return loadMediaFileForSourceBodyReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
class CompletionSuggestionServiceMock: CompletionSuggestionServiceProtocol {
|
class CompletionSuggestionServiceMock: CompletionSuggestionServiceProtocol {
|
||||||
var suggestionsPublisher: AnyPublisher<[SuggestionItem], Never> {
|
var suggestionsPublisher: AnyPublisher<[SuggestionItem], Never> {
|
||||||
get { return underlyingSuggestionsPublisher }
|
get { return underlyingSuggestionsPublisher }
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ extension View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ShimmerOverlay_Previews: PreviewProvider, TestablePreview {
|
struct ShimmerOverlay_Previews: PreviewProvider, TestablePreview {
|
||||||
static let viewModel = HomeScreenViewModel(userSession: MockUserSession(clientProxy: MockClientProxy(userID: ""),
|
static let viewModel = HomeScreenViewModel(userSession: MockUserSession(clientProxy: ClientProxyMock(.init(userID: "")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock()),
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock()),
|
||||||
analyticsService: ServiceLocator.shared.analytics,
|
analyticsService: ServiceLocator.shared.analytics,
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ struct WaitlistScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
static let viewModel = WaitlistScreenViewModel(homeserver: .mockMatrixDotOrg)
|
static let viewModel = WaitlistScreenViewModel(homeserver: .mockMatrixDotOrg)
|
||||||
static let successViewModel = {
|
static let successViewModel = {
|
||||||
let viewModel = WaitlistScreenViewModel(homeserver: .mockMatrixDotOrg)
|
let viewModel = WaitlistScreenViewModel(homeserver: .mockMatrixDotOrg)
|
||||||
viewModel.update(userSession: MockUserSession(clientProxy: MockClientProxy(userID: "@alice:matrix.org"),
|
viewModel.update(userSession: MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@alice:matrix.org")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock()))
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock()))
|
||||||
return viewModel
|
return viewModel
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ struct BlockedUsersScreen: View {
|
|||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
struct BlockedUsersScreen_Previews: PreviewProvider, TestablePreview {
|
struct BlockedUsersScreen_Previews: PreviewProvider, TestablePreview {
|
||||||
static let viewModel = BlockedUsersScreenViewModel(clientProxy: MockClientProxy(userID: RoomMemberProxyMock.mockMe.userID),
|
static let viewModel = BlockedUsersScreenViewModel(clientProxy: ClientProxyMock(.init(userID: RoomMemberProxyMock.mockMe.userID)),
|
||||||
userIndicatorController: UserIndicatorControllerMock())
|
userIndicatorController: UserIndicatorControllerMock())
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ struct CreateRoomScreen: View {
|
|||||||
|
|
||||||
struct CreateRoom_Previews: PreviewProvider, TestablePreview {
|
struct CreateRoom_Previews: PreviewProvider, TestablePreview {
|
||||||
static let viewModel = {
|
static let viewModel = {
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com"),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
let parameters = CreateRoomFlowParameters()
|
let parameters = CreateRoomFlowParameters()
|
||||||
@@ -189,7 +189,7 @@ struct CreateRoom_Previews: PreviewProvider, TestablePreview {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
static let emtpyViewModel = {
|
static let emtpyViewModel = {
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com"),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
let parameters = CreateRoomFlowParameters()
|
let parameters = CreateRoomFlowParameters()
|
||||||
|
|||||||
@@ -242,8 +242,8 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
.loaded(.mockRooms)
|
.loaded(.mockRooms)
|
||||||
}
|
}
|
||||||
|
|
||||||
let clientProxy = MockClientProxy(userID: userID,
|
let clientProxy = ClientProxyMock(.init(userID: userID,
|
||||||
roomSummaryProvider: MockRoomSummaryProvider(state: roomSummaryProviderState))
|
roomSummaryProvider: MockRoomSummaryProvider(state: roomSummaryProviderState)))
|
||||||
|
|
||||||
let userSession = MockUserSession(clientProxy: clientProxy,
|
let userSession = MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
|
|||||||
@@ -149,8 +149,8 @@ struct HomeScreenEmptyStateView_Previews: PreviewProvider, TestablePreview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static let viewModel = {
|
static let viewModel = {
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@user:example.com",
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@user:example.com",
|
||||||
roomSummaryProvider: MockRoomSummaryProvider(state: .loaded([]))),
|
roomSummaryProvider: MockRoomSummaryProvider(state: .loaded([])))),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -65,8 +65,8 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func buildViewModel() -> HomeScreenViewModel {
|
static func buildViewModel() -> HomeScreenViewModel {
|
||||||
let clientProxy = MockClientProxy(userID: "@alice:example.com",
|
let clientProxy = ClientProxyMock(.init(userID: "@alice:example.com",
|
||||||
roomSummaryProvider: MockRoomSummaryProvider(state: .loading))
|
roomSummaryProvider: MockRoomSummaryProvider(state: .loading)))
|
||||||
|
|
||||||
let userSession = MockUserSession(clientProxy: clientProxy,
|
let userSession = MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ private extension View {
|
|||||||
struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
||||||
static let summaryProviderGeneric = MockRoomSummaryProvider(state: .loaded(.mockRooms))
|
static let summaryProviderGeneric = MockRoomSummaryProvider(state: .loaded(.mockRooms))
|
||||||
static let viewModelGeneric = {
|
static let viewModelGeneric = {
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe", roomSummaryProvider: summaryProviderGeneric),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "John Doe", roomSummaryProvider: summaryProviderGeneric)),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
|||||||
|
|
||||||
static let summaryProviderForNotificationsState = MockRoomSummaryProvider(state: .loaded(.mockRoomsWithNotificationsState))
|
static let summaryProviderForNotificationsState = MockRoomSummaryProvider(state: .loaded(.mockRoomsWithNotificationsState))
|
||||||
static let viewModelForNotificationsState = {
|
static let viewModelForNotificationsState = {
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe", roomSummaryProvider: summaryProviderForNotificationsState),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "John Doe", roomSummaryProvider: summaryProviderForNotificationsState)),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ struct HomeScreenSessionVerificationBanner_Previews: PreviewProvider, TestablePr
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func buildViewModel() -> HomeScreenViewModel {
|
static func buildViewModel() -> HomeScreenViewModel {
|
||||||
let clientProxy = MockClientProxy(userID: "@alice:example.com",
|
let clientProxy = ClientProxyMock(.init(userID: "@alice:example.com",
|
||||||
roomSummaryProvider: MockRoomSummaryProvider(state: .loading))
|
roomSummaryProvider: MockRoomSummaryProvider(state: .loading)))
|
||||||
|
|
||||||
let userSession = MockUserSession(clientProxy: clientProxy,
|
let userSession = MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ struct InvitesScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
|
|
||||||
private extension InvitesScreenViewModel {
|
private extension InvitesScreenViewModel {
|
||||||
static let noInvites: InvitesScreenViewModel = {
|
static let noInvites: InvitesScreenViewModel = {
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com"),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
let regularViewModel = InvitesScreenViewModel(userSession: userSession,
|
let regularViewModel = InvitesScreenViewModel(userSession: userSession,
|
||||||
@@ -91,7 +91,7 @@ private extension InvitesScreenViewModel {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
static let someInvite: InvitesScreenViewModel = {
|
static let someInvite: InvitesScreenViewModel = {
|
||||||
let clientProxy = MockClientProxy(userID: "@userid:example.com")
|
let clientProxy = ClientProxyMock(.init(userID: "@userid:example.com"))
|
||||||
clientProxy.inviteSummaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
|
clientProxy.inviteSummaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
|
||||||
clientProxy.roomSummaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
|
clientProxy.roomSummaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
|
||||||
let userSession = MockUserSession(clientProxy: clientProxy,
|
let userSession = MockUserSession(clientProxy: clientProxy,
|
||||||
|
|||||||
+9
-7
@@ -73,8 +73,8 @@ struct NotificationSettingsEditScreen_Previews: PreviewProvider, TestablePreview
|
|||||||
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .allMessages
|
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .allMessages
|
||||||
|
|
||||||
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = [RoomSummary].mockRooms.compactMap(\.id)
|
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = [RoomSummary].mockRooms.compactMap(\.id)
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@alice:example.com",
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@alice:example.com",
|
||||||
roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms))),
|
roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms)))),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
var viewModel = NotificationSettingsEditScreenViewModel(chatType: .groupChat,
|
var viewModel = NotificationSettingsEditScreenViewModel(chatType: .groupChat,
|
||||||
@@ -88,8 +88,8 @@ struct NotificationSettingsEditScreen_Previews: PreviewProvider, TestablePreview
|
|||||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
||||||
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .mentionsAndKeywordsOnly
|
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .mentionsAndKeywordsOnly
|
||||||
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = []
|
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = []
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@alice:example.com",
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@alice:example.com",
|
||||||
roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms))),
|
roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms)))),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
var viewModel = NotificationSettingsEditScreenViewModel(chatType: .oneToOneChat,
|
var viewModel = NotificationSettingsEditScreenViewModel(chatType: .oneToOneChat,
|
||||||
@@ -103,7 +103,9 @@ struct NotificationSettingsEditScreen_Previews: PreviewProvider, TestablePreview
|
|||||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
||||||
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .mentionsAndKeywordsOnly
|
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .mentionsAndKeywordsOnly
|
||||||
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = []
|
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = []
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe"), mediaProvider: MockMediaProvider(), voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "John Doe")),
|
||||||
|
mediaProvider: MockMediaProvider(),
|
||||||
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|
||||||
var viewModel = NotificationSettingsEditScreenViewModel(chatType: .oneToOneChat,
|
var viewModel = NotificationSettingsEditScreenViewModel(chatType: .oneToOneChat,
|
||||||
userSession: userSession,
|
userSession: userSession,
|
||||||
@@ -118,8 +120,8 @@ struct NotificationSettingsEditScreen_Previews: PreviewProvider, TestablePreview
|
|||||||
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .allMessages
|
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .allMessages
|
||||||
|
|
||||||
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = [RoomSummary].mockRooms.compactMap(\.id)
|
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = [RoomSummary].mockRooms.compactMap(\.id)
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@alice:example.com",
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@alice:example.com",
|
||||||
roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms))),
|
roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms)))),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
var viewModel = NotificationSettingsEditScreenViewModel(chatType: .groupChat,
|
var viewModel = NotificationSettingsEditScreenViewModel(chatType: .groupChat,
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ struct NotificationSettingsEditScreenRoomCell_Previews: PreviewProvider, Testabl
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
let summaryProvider = MockRoomSummaryProvider(state: .loaded(.mockRooms))
|
let summaryProvider = MockRoomSummaryProvider(state: .loaded(.mockRooms))
|
||||||
|
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe", roomSummaryProvider: summaryProvider),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "John Doe", roomSummaryProvider: summaryProvider)),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -222,7 +222,8 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
notificationSettingsProxy.isRoomMentionEnabledReturnValue = true
|
notificationSettingsProxy.isRoomMentionEnabledReturnValue = true
|
||||||
notificationSettingsProxy.isCallEnabledReturnValue = false
|
notificationSettingsProxy.isCallEnabledReturnValue = false
|
||||||
|
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe"), mediaProvider: MockMediaProvider(),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "John Doe")),
|
||||||
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|
||||||
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
||||||
@@ -251,7 +252,9 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
notificationSettingsProxy.isRoomMentionEnabledReturnValue = true
|
notificationSettingsProxy.isRoomMentionEnabledReturnValue = true
|
||||||
notificationSettingsProxy.isCallEnabledReturnValue = false
|
notificationSettingsProxy.isCallEnabledReturnValue = false
|
||||||
|
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe"), mediaProvider: MockMediaProvider(), voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "John Doe")),
|
||||||
|
mediaProvider: MockMediaProvider(),
|
||||||
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|
||||||
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
||||||
userNotificationCenter: notificationCenter,
|
userNotificationCenter: notificationCenter,
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
let verificationController = SessionVerificationControllerProxyMock()
|
let verificationController = SessionVerificationControllerProxyMock()
|
||||||
verificationController.isVerifiedReturnValue = .success(false)
|
verificationController.isVerifiedReturnValue = .success(false)
|
||||||
let userSession = MockUserSession(sessionVerificationController: verificationController,
|
let userSession = MockUserSession(sessionVerificationController: verificationController,
|
||||||
clientProxy: MockClientProxy(userID: "@userid:example.com",
|
clientProxy: ClientProxyMock(.init(userID: "@userid:example.com",
|
||||||
deviceID: "AAAAAAAAAAA"),
|
deviceID: "AAAAAAAAAAA")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
return SettingsScreenViewModel(userSession: userSession,
|
return SettingsScreenViewModel(userSession: userSession,
|
||||||
|
|||||||
+1
-1
@@ -124,7 +124,7 @@ struct UserDetailsEditScreen: View {
|
|||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
struct UserDetailsEditScreen_Previews: PreviewProvider, TestablePreview {
|
struct UserDetailsEditScreen_Previews: PreviewProvider, TestablePreview {
|
||||||
static let viewModel = UserDetailsEditScreenViewModel(clientProxy: MockClientProxy(userID: "@stefan:matrix.org"),
|
static let viewModel = UserDetailsEditScreenViewModel(clientProxy: ClientProxyMock(.init(userID: "@stefan:matrix.org")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
userIndicatorController: UserIndicatorControllerMock.default)
|
userIndicatorController: UserIndicatorControllerMock.default)
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ struct StartChatScreen: View {
|
|||||||
|
|
||||||
struct StartChatScreen_Previews: PreviewProvider, TestablePreview {
|
struct StartChatScreen_Previews: PreviewProvider, TestablePreview {
|
||||||
static let viewModel = {
|
static let viewModel = {
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com"),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
let userDiscoveryService = UserDiscoveryServiceMock()
|
let userDiscoveryService = UserDiscoveryServiceMock()
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class MockAuthenticationServiceProxy: AuthenticationServiceProxyProtocol {
|
|||||||
return .failure(.invalidCredentials)
|
return .failure(.invalidCredentials)
|
||||||
}
|
}
|
||||||
|
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: username),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: username)),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
return .success(userSession)
|
return .success(userSession)
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ struct PusherConfiguration {
|
|||||||
let lang: String
|
let lang: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sourcery: AutoMockable
|
||||||
protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
||||||
var actionsPublisher: AnyPublisher<ClientProxyAction, Never> { get }
|
var actionsPublisher: AnyPublisher<ClientProxyAction, Never> { get }
|
||||||
|
|
||||||
|
|||||||
@@ -1,185 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright 2022 New Vector Ltd
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Combine
|
|
||||||
import Foundation
|
|
||||||
import MatrixRustSDK
|
|
||||||
|
|
||||||
class MockClientProxy: ClientProxyProtocol {
|
|
||||||
let actionsSubject = PassthroughSubject<ClientProxyAction, Never>()
|
|
||||||
var actionsPublisher: AnyPublisher<ClientProxyAction, Never> {
|
|
||||||
actionsSubject.eraseToAnyPublisher()
|
|
||||||
}
|
|
||||||
|
|
||||||
let loadingStatePublisher = CurrentValuePublisher<ClientProxyLoadingState, Never>(.notLoading)
|
|
||||||
|
|
||||||
let userID: String
|
|
||||||
let deviceID: String?
|
|
||||||
let homeserver = ""
|
|
||||||
let pusherNotificationClientIdentifier: String? = nil
|
|
||||||
|
|
||||||
var roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()
|
|
||||||
|
|
||||||
var alternateRoomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()
|
|
||||||
|
|
||||||
var inviteSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()
|
|
||||||
|
|
||||||
var userAvatarURLPublisher: CurrentValuePublisher<URL?, Never> { CurrentValueSubject<URL?, Never>(nil).asCurrentValuePublisher() }
|
|
||||||
|
|
||||||
var userDisplayNamePublisher: CurrentValuePublisher<String?, Never> { CurrentValueSubject<String?, Never>("User display name").asCurrentValuePublisher() }
|
|
||||||
|
|
||||||
var ignoredUsersPublisher: CurrentValuePublisher<[String]?, Never> {
|
|
||||||
let ignoredUsers = [RoomMemberProxyMock].allMembers.map(\.userID)
|
|
||||||
return CurrentValueSubject<[String]?, Never>(ignoredUsers).asCurrentValuePublisher()
|
|
||||||
}
|
|
||||||
|
|
||||||
var notificationSettings: NotificationSettingsProxyProtocol = NotificationSettingsProxyMock(with: .init())
|
|
||||||
|
|
||||||
lazy var secureBackupController: SecureBackupControllerProtocol = {
|
|
||||||
let secureBackupController = SecureBackupControllerMock()
|
|
||||||
secureBackupController.underlyingRecoveryState = .init(CurrentValueSubject<SecureBackupRecoveryState, Never>(.enabled))
|
|
||||||
secureBackupController.underlyingKeyBackupState = .init(CurrentValueSubject<SecureBackupKeyBackupState, Never>(.enabled))
|
|
||||||
return secureBackupController
|
|
||||||
}()
|
|
||||||
|
|
||||||
init(userID: String, deviceID: String? = nil, roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()) {
|
|
||||||
self.userID = userID
|
|
||||||
self.deviceID = deviceID
|
|
||||||
self.roomSummaryProvider = roomSummaryProvider
|
|
||||||
}
|
|
||||||
|
|
||||||
func isOnlyDeviceLeft() async -> Result<Bool, ClientProxyError> {
|
|
||||||
.success(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func startSync() { }
|
|
||||||
|
|
||||||
func stopSync() { }
|
|
||||||
|
|
||||||
func accountURL(action: AccountManagementAction) -> URL? {
|
|
||||||
"https://matrix.org/account"
|
|
||||||
}
|
|
||||||
|
|
||||||
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError> {
|
|
||||||
.failure(.failedRetrievingDirectRoom)
|
|
||||||
}
|
|
||||||
|
|
||||||
func createDirectRoom(with userID: String, expectedRoomName: String?) async -> Result<String, ClientProxyError> {
|
|
||||||
.failure(.failedCreatingRoom)
|
|
||||||
}
|
|
||||||
|
|
||||||
func createRoom(name: String, topic: String?, isRoomPrivate: Bool, userIDs: [String], avatarURL: URL?) async -> Result<String, ClientProxyError> {
|
|
||||||
.failure(.failedCreatingRoom)
|
|
||||||
}
|
|
||||||
|
|
||||||
func uploadMedia(_ media: MediaInfo) async -> Result<String, ClientProxyError> {
|
|
||||||
.failure(.failedUploadingMedia(.unknown))
|
|
||||||
}
|
|
||||||
|
|
||||||
var roomForIdentifierMocks: [String: RoomProxyMock] = .init()
|
|
||||||
@MainActor
|
|
||||||
func roomForIdentifier(_ identifier: String) async -> RoomProxyProtocol? {
|
|
||||||
guard roomForIdentifierMocks[identifier] == nil else {
|
|
||||||
return roomForIdentifierMocks[identifier]
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let room = roomSummaryProvider?.roomListPublisher.value.first(where: { $0.id == identifier }) else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
switch room {
|
|
||||||
case .empty:
|
|
||||||
return RoomProxyMock(with: .init(name: "Empty room"))
|
|
||||||
case .filled(let details), .invalidated(let details):
|
|
||||||
return RoomProxyMock(with: .init(name: details.name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadUserDisplayName() async -> Result<Void, ClientProxyError> {
|
|
||||||
.failure(.failedRetrievingUserDisplayName)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setUserDisplayName(_ name: String) async -> Result<Void, ClientProxyError> {
|
|
||||||
.failure(.failedSettingUserDisplayName)
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadUserAvatarURL() async -> Result<Void, ClientProxyError> {
|
|
||||||
.failure(.failedRetrievingUserAvatarURL)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setUserAvatar(media: MediaInfo) async -> Result<Void, ClientProxyError> {
|
|
||||||
.failure(.failedSettingUserAvatar)
|
|
||||||
}
|
|
||||||
|
|
||||||
func removeUserAvatar() async -> Result<Void, ClientProxyError> {
|
|
||||||
.failure(.failedSettingUserAvatar)
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadMediaContentForSource(_ source: MediaSourceProxy) async throws -> Data {
|
|
||||||
throw ClientProxyError.failedLoadingMedia
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadMediaThumbnailForSource(_ source: MediaSourceProxy, width: UInt, height: UInt) async throws -> Data {
|
|
||||||
throw ClientProxyError.failedLoadingMedia
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy {
|
|
||||||
throw ClientProxyError.failedLoadingMedia
|
|
||||||
}
|
|
||||||
|
|
||||||
var sessionVerificationControllerProxyResult: Result<SessionVerificationControllerProxyProtocol, ClientProxyError>?
|
|
||||||
func sessionVerificationControllerProxy() async -> Result<SessionVerificationControllerProxyProtocol, ClientProxyError> {
|
|
||||||
if let sessionVerificationControllerProxyResult {
|
|
||||||
return sessionVerificationControllerProxyResult
|
|
||||||
} else {
|
|
||||||
return .failure(.failedRetrievingSessionVerificationController)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func logout() async -> URL? {
|
|
||||||
nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var setPusherErrorToThrow: Error?
|
|
||||||
var setPusherArgument: PusherConfiguration?
|
|
||||||
var setPusherCalled = false
|
|
||||||
|
|
||||||
func setPusher(with configuration: PusherConfiguration) async throws {
|
|
||||||
if let setPusherErrorToThrow { throw setPusherErrorToThrow }
|
|
||||||
setPusherCalled = true
|
|
||||||
setPusherArgument = configuration
|
|
||||||
}
|
|
||||||
|
|
||||||
var searchUsersResult: Result<SearchUsersResultsProxy, ClientProxyError> = .success(.init(results: [], limited: false))
|
|
||||||
func searchUsers(searchTerm: String, limit: UInt) async -> Result<SearchUsersResultsProxy, ClientProxyError> {
|
|
||||||
searchUsersResult
|
|
||||||
}
|
|
||||||
|
|
||||||
var getProfileResult: Result<UserProfileProxy, ClientProxyError> = .success(.init(userID: "@a:b.com", displayName: "Some user"))
|
|
||||||
private(set) var getProfileCalled = false
|
|
||||||
func profile(for userID: String) async -> Result<UserProfileProxy, ClientProxyError> {
|
|
||||||
getProfileCalled = true
|
|
||||||
return getProfileResult
|
|
||||||
}
|
|
||||||
|
|
||||||
func ignoreUser(_ userID: String) async -> Result<Void, ClientProxyError> {
|
|
||||||
.failure(.failedIgnoringUser)
|
|
||||||
}
|
|
||||||
|
|
||||||
func unignoreUser(_ userID: String) async -> Result<Void, ClientProxyError> {
|
|
||||||
.failure(.failedUnignoringUser)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -261,7 +261,7 @@ class MockScreen: Identifiable {
|
|||||||
ServiceLocator.shared.settings.migratedAccounts[userID] = true
|
ServiceLocator.shared.settings.migratedAccounts[userID] = true
|
||||||
|
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let session = MockUserSession(clientProxy: MockClientProxy(userID: userID),
|
let session = MockUserSession(clientProxy: ClientProxyMock(.init(userID: userID)),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
let coordinator = HomeScreenCoordinator(parameters: .init(userSession: session,
|
let coordinator = HomeScreenCoordinator(parameters: .init(userSession: session,
|
||||||
@@ -273,7 +273,7 @@ class MockScreen: Identifiable {
|
|||||||
return navigationStackCoordinator
|
return navigationStackCoordinator
|
||||||
case .settings:
|
case .settings:
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let clientProxy = MockClientProxy(userID: "@mock:client.com")
|
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com"))
|
||||||
let coordinator = SettingsScreenCoordinator(parameters: .init(userSession: MockUserSession(clientProxy: clientProxy,
|
let coordinator = SettingsScreenCoordinator(parameters: .init(userSession: MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock()),
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock()),
|
||||||
@@ -303,7 +303,7 @@ class MockScreen: Identifiable {
|
|||||||
case .notificationSettingsScreen:
|
case .notificationSettingsScreen:
|
||||||
let userNotificationCenter = UserNotificationCenterMock()
|
let userNotificationCenter = UserNotificationCenterMock()
|
||||||
userNotificationCenter.authorizationStatusReturnValue = .denied
|
userNotificationCenter.authorizationStatusReturnValue = .denied
|
||||||
let session = MockUserSession(clientProxy: MockClientProxy(userID: "@mock:matrix.org"),
|
let session = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@mock:matrix.org")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
let parameters = NotificationSettingsScreenCoordinatorParameters(userSession: session,
|
let parameters = NotificationSettingsScreenCoordinatorParameters(userSession: session,
|
||||||
@@ -314,7 +314,7 @@ class MockScreen: Identifiable {
|
|||||||
case .notificationSettingsScreenMismatchConfiguration:
|
case .notificationSettingsScreenMismatchConfiguration:
|
||||||
let userNotificationCenter = UserNotificationCenterMock()
|
let userNotificationCenter = UserNotificationCenterMock()
|
||||||
userNotificationCenter.authorizationStatusReturnValue = .denied
|
userNotificationCenter.authorizationStatusReturnValue = .denied
|
||||||
let session = MockUserSession(clientProxy: MockClientProxy(userID: "@mock:matrix.org"),
|
let session = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@mock:matrix.org")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
let notificationSettings = NotificationSettingsProxyMock(with: .init())
|
let notificationSettings = NotificationSettingsProxyMock(with: .init())
|
||||||
@@ -560,7 +560,7 @@ class MockScreen: Identifiable {
|
|||||||
appSettings.richTextEditorEnabled = id == .userSessionScreenRTE
|
appSettings.richTextEditorEnabled = id == .userSessionScreenRTE
|
||||||
let navigationSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator())
|
let navigationSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator())
|
||||||
|
|
||||||
let clientProxy = MockClientProxy(userID: "@mock:client.com", roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms)))
|
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms))))
|
||||||
ServiceLocator.shared.settings.migratedAccounts[clientProxy.userID] = true
|
ServiceLocator.shared.settings.migratedAccounts[clientProxy.userID] = true
|
||||||
ServiceLocator.shared.settings.hasShownWelcomeScreen = true
|
ServiceLocator.shared.settings.hasShownWelcomeScreen = true
|
||||||
|
|
||||||
@@ -743,7 +743,9 @@ class MockScreen: Identifiable {
|
|||||||
let userDiscoveryMock = UserDiscoveryServiceMock()
|
let userDiscoveryMock = UserDiscoveryServiceMock()
|
||||||
userDiscoveryMock.fetchSuggestionsReturnValue = .success([.mockAlice, .mockBob, .mockCharlie])
|
userDiscoveryMock.fetchSuggestionsReturnValue = .success([.mockAlice, .mockBob, .mockCharlie])
|
||||||
userDiscoveryMock.searchProfilesWithReturnValue = .success([])
|
userDiscoveryMock.searchProfilesWithReturnValue = .success([])
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@mock:client.com"), mediaProvider: MockMediaProvider(), voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@mock:client.com")),
|
||||||
|
mediaProvider: MockMediaProvider(),
|
||||||
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
let parameters: StartChatScreenCoordinatorParameters = .init(orientationManager: OrientationManagerMock(),
|
let parameters: StartChatScreenCoordinatorParameters = .init(orientationManager: OrientationManagerMock(),
|
||||||
userSession: userSession,
|
userSession: userSession,
|
||||||
userIndicatorController: UserIndicatorControllerMock(),
|
userIndicatorController: UserIndicatorControllerMock(),
|
||||||
@@ -754,7 +756,7 @@ class MockScreen: Identifiable {
|
|||||||
return navigationStackCoordinator
|
return navigationStackCoordinator
|
||||||
case .startChatWithSearchResults:
|
case .startChatWithSearchResults:
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let clientProxy = MockClientProxy(userID: "@mock:client.com")
|
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com"))
|
||||||
let userDiscoveryMock = UserDiscoveryServiceMock()
|
let userDiscoveryMock = UserDiscoveryServiceMock()
|
||||||
userDiscoveryMock.fetchSuggestionsReturnValue = .success([])
|
userDiscoveryMock.fetchSuggestionsReturnValue = .success([])
|
||||||
userDiscoveryMock.searchProfilesWithReturnValue = .success([.mockBob, .mockBobby])
|
userDiscoveryMock.searchProfilesWithReturnValue = .success([.mockBob, .mockBobby])
|
||||||
@@ -805,9 +807,19 @@ class MockScreen: Identifiable {
|
|||||||
case .invitesWithBadges:
|
case .invitesWithBadges:
|
||||||
ServiceLocator.shared.settings.seenInvites = Set([RoomSummary].mockInvites.dropFirst(1).compactMap(\.id))
|
ServiceLocator.shared.settings.seenInvites = Set([RoomSummary].mockInvites.dropFirst(1).compactMap(\.id))
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let clientProxy = MockClientProxy(userID: "@mock:client.com")
|
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com"))
|
||||||
clientProxy.roomForIdentifierMocks["someAwesomeRoomId1"] = .init(with: .init(name: "First room"))
|
|
||||||
clientProxy.roomForIdentifierMocks["someAwesomeRoomId2"] = .init(with: .init(name: "Second room"))
|
clientProxy.roomForIdentifierClosure = { identifier in
|
||||||
|
switch identifier {
|
||||||
|
case "someAwesomeRoomId1":
|
||||||
|
return RoomProxyMock(with: .init(name: "First room"))
|
||||||
|
case "someAwesomeRoomId2":
|
||||||
|
return RoomProxyMock(with: .init(name: "Second room"))
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let summaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
|
let summaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
|
||||||
clientProxy.inviteSummaryProvider = summaryProvider
|
clientProxy.inviteSummaryProvider = summaryProvider
|
||||||
|
|
||||||
@@ -817,9 +829,19 @@ class MockScreen: Identifiable {
|
|||||||
case .invites:
|
case .invites:
|
||||||
ServiceLocator.shared.settings.seenInvites = Set([RoomSummary].mockInvites.compactMap(\.id))
|
ServiceLocator.shared.settings.seenInvites = Set([RoomSummary].mockInvites.compactMap(\.id))
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let clientProxy = MockClientProxy(userID: "@mock:client.com")
|
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com"))
|
||||||
clientProxy.roomForIdentifierMocks["someAwesomeRoomId1"] = .init(with: .init(name: "First room"))
|
|
||||||
clientProxy.roomForIdentifierMocks["someAwesomeRoomId2"] = .init(with: .init(name: "Second room"))
|
clientProxy.roomForIdentifierClosure = { identifier in
|
||||||
|
switch identifier {
|
||||||
|
case "someAwesomeRoomId1":
|
||||||
|
return RoomProxyMock(with: .init(name: "First room"))
|
||||||
|
case "someAwesomeRoomId2":
|
||||||
|
return RoomProxyMock(with: .init(name: "Second room"))
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let summaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
|
let summaryProvider = MockRoomSummaryProvider(state: .loaded(.mockInvites))
|
||||||
clientProxy.inviteSummaryProvider = summaryProvider
|
clientProxy.inviteSummaryProvider = summaryProvider
|
||||||
|
|
||||||
@@ -828,7 +850,7 @@ class MockScreen: Identifiable {
|
|||||||
return navigationStackCoordinator
|
return navigationStackCoordinator
|
||||||
case .invitesNoInvites:
|
case .invitesNoInvites:
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let clientProxy = MockClientProxy(userID: "@mock:client.com")
|
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com"))
|
||||||
let coordinator = InvitesScreenCoordinator(parameters: .init(userSession: MockUserSession(clientProxy: clientProxy, mediaProvider: MockMediaProvider(), voiceMessageMediaManager: VoiceMessageMediaManagerMock())))
|
let coordinator = InvitesScreenCoordinator(parameters: .init(userSession: MockUserSession(clientProxy: clientProxy, mediaProvider: MockMediaProvider(), voiceMessageMediaManager: VoiceMessageMediaManagerMock())))
|
||||||
navigationStackCoordinator.setRootCoordinator(coordinator)
|
navigationStackCoordinator.setRootCoordinator(coordinator)
|
||||||
return navigationStackCoordinator
|
return navigationStackCoordinator
|
||||||
@@ -867,7 +889,7 @@ class MockScreen: Identifiable {
|
|||||||
return navigationStackCoordinator
|
return navigationStackCoordinator
|
||||||
case .createRoom:
|
case .createRoom:
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let clientProxy = MockClientProxy(userID: "@mock:client.com")
|
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com"))
|
||||||
let mockUserSession = MockUserSession(clientProxy: clientProxy, mediaProvider: MockMediaProvider(), voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
let mockUserSession = MockUserSession(clientProxy: clientProxy, mediaProvider: MockMediaProvider(), voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
let createRoomParameters = CreateRoomFlowParameters()
|
let createRoomParameters = CreateRoomFlowParameters()
|
||||||
let selectedUsers: [UserProfileProxy] = [.mockAlice, .mockBob, .mockCharlie]
|
let selectedUsers: [UserProfileProxy] = [.mockAlice, .mockBob, .mockCharlie]
|
||||||
@@ -880,7 +902,7 @@ class MockScreen: Identifiable {
|
|||||||
return navigationStackCoordinator
|
return navigationStackCoordinator
|
||||||
case .createRoomNoUsers:
|
case .createRoomNoUsers:
|
||||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||||
let clientProxy = MockClientProxy(userID: "@mock:client.com")
|
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com"))
|
||||||
let mockUserSession = MockUserSession(clientProxy: clientProxy,
|
let mockUserSession = MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import XCTest
|
|||||||
@MainActor
|
@MainActor
|
||||||
class BlockedUsersScreenViewModelTests: XCTestCase {
|
class BlockedUsersScreenViewModelTests: XCTestCase {
|
||||||
func testInitialState() {
|
func testInitialState() {
|
||||||
let clientProxy = MockClientProxy(userID: RoomMemberProxyMock.mockMe.userID)
|
let clientProxy = ClientProxyMock(.init(userID: RoomMemberProxyMock.mockMe.userID))
|
||||||
|
|
||||||
let viewModel = BlockedUsersScreenViewModel(clientProxy: clientProxy,
|
let viewModel = BlockedUsersScreenViewModel(clientProxy: clientProxy,
|
||||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import XCTest
|
|||||||
@MainActor
|
@MainActor
|
||||||
class CreateRoomScreenViewModelTests: XCTestCase {
|
class CreateRoomScreenViewModelTests: XCTestCase {
|
||||||
var viewModel: CreateRoomViewModelProtocol!
|
var viewModel: CreateRoomViewModelProtocol!
|
||||||
var clientProxy: MockClientProxy!
|
var clientProxy: ClientProxyMock!
|
||||||
var userSession: MockUserSession!
|
var userSession: MockUserSession!
|
||||||
|
|
||||||
private let usersSubject = CurrentValueSubject<[UserProfileProxy], Never>([])
|
private let usersSubject = CurrentValueSubject<[UserProfileProxy], Never>([])
|
||||||
@@ -34,7 +34,7 @@ class CreateRoomScreenViewModelTests: XCTestCase {
|
|||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
cancellables.removeAll()
|
cancellables.removeAll()
|
||||||
clientProxy = MockClientProxy(userID: "@a:b.com")
|
clientProxy = ClientProxyMock(.init(userID: "@a:b.com"))
|
||||||
userSession = MockUserSession(clientProxy: clientProxy,
|
userSession = MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import XCTest
|
|||||||
@MainActor
|
@MainActor
|
||||||
class HomeScreenViewModelTests: XCTestCase {
|
class HomeScreenViewModelTests: XCTestCase {
|
||||||
var viewModel: HomeScreenViewModelProtocol!
|
var viewModel: HomeScreenViewModelProtocol!
|
||||||
var clientProxy: MockClientProxy!
|
var clientProxy: ClientProxyMock!
|
||||||
var context: HomeScreenViewModelType.Context! { viewModel.context }
|
var context: HomeScreenViewModelType.Context! { viewModel.context }
|
||||||
var cancellables = Set<AnyCancellable>()
|
var cancellables = Set<AnyCancellable>()
|
||||||
var roomSummaryProvider: MockRoomSummaryProvider!
|
var roomSummaryProvider: MockRoomSummaryProvider!
|
||||||
@@ -31,7 +31,7 @@ class HomeScreenViewModelTests: XCTestCase {
|
|||||||
ServiceLocator.shared.settings.roomListFiltersEnabled = true
|
ServiceLocator.shared.settings.roomListFiltersEnabled = true
|
||||||
cancellables.removeAll()
|
cancellables.removeAll()
|
||||||
roomSummaryProvider = MockRoomSummaryProvider(state: .loaded(.mockRooms))
|
roomSummaryProvider = MockRoomSummaryProvider(state: .loaded(.mockRooms))
|
||||||
clientProxy = MockClientProxy(userID: "@mock:client.com", roomSummaryProvider: roomSummaryProvider)
|
clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: roomSummaryProvider))
|
||||||
viewModel = HomeScreenViewModel(userSession: MockUserSession(clientProxy: clientProxy,
|
viewModel = HomeScreenViewModel(userSession: MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock()),
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock()),
|
||||||
@@ -89,7 +89,8 @@ class HomeScreenViewModelTests: XCTestCase {
|
|||||||
|
|
||||||
func testLeaveRoomAlert() async throws {
|
func testLeaveRoomAlert() async throws {
|
||||||
let mockRoomId = "1"
|
let mockRoomId = "1"
|
||||||
clientProxy.roomForIdentifierMocks[mockRoomId] = .init(with: .init(id: mockRoomId, name: "Some room"))
|
|
||||||
|
clientProxy.roomForIdentifierClosure = { _ in RoomProxyMock(with: .init(id: mockRoomId, name: "Some room")) }
|
||||||
|
|
||||||
let deferred = deferFulfillment(context.$viewState) { value in
|
let deferred = deferFulfillment(context.$viewState) { value in
|
||||||
value.bindings.leaveRoomAlertItem != nil
|
value.bindings.leaveRoomAlertItem != nil
|
||||||
@@ -106,7 +107,8 @@ class HomeScreenViewModelTests: XCTestCase {
|
|||||||
let mockRoomId = "1"
|
let mockRoomId = "1"
|
||||||
let room: RoomProxyMock = .init(with: .init(id: mockRoomId, name: "Some room"))
|
let room: RoomProxyMock = .init(with: .init(id: mockRoomId, name: "Some room"))
|
||||||
room.leaveRoomClosure = { .failure(.failedLeavingRoom) }
|
room.leaveRoomClosure = { .failure(.failedLeavingRoom) }
|
||||||
clientProxy.roomForIdentifierMocks[mockRoomId] = room
|
|
||||||
|
clientProxy.roomForIdentifierClosure = { _ in room }
|
||||||
|
|
||||||
let deferred = deferFulfillment(context.$viewState) { value in
|
let deferred = deferFulfillment(context.$viewState) { value in
|
||||||
value.bindings.alertInfo != nil
|
value.bindings.alertInfo != nil
|
||||||
@@ -136,7 +138,9 @@ class HomeScreenViewModelTests: XCTestCase {
|
|||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
let room: RoomProxyMock = .init(with: .init(id: mockRoomId, name: "Some room"))
|
let room: RoomProxyMock = .init(with: .init(id: mockRoomId, name: "Some room"))
|
||||||
room.leaveRoomClosure = { .success(()) }
|
room.leaveRoomClosure = { .success(()) }
|
||||||
clientProxy.roomForIdentifierMocks[mockRoomId] = room
|
|
||||||
|
clientProxy.roomForIdentifierClosure = { _ in room }
|
||||||
|
|
||||||
context.send(viewAction: .confirmLeaveRoom(roomIdentifier: mockRoomId))
|
context.send(viewAction: .confirmLeaveRoom(roomIdentifier: mockRoomId))
|
||||||
await fulfillment(of: [expectation])
|
await fulfillment(of: [expectation])
|
||||||
XCTAssertNil(context.alertInfo)
|
XCTAssertNil(context.alertInfo)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import XCTest
|
|||||||
@MainActor
|
@MainActor
|
||||||
class InvitesScreenViewModelTests: XCTestCase {
|
class InvitesScreenViewModelTests: XCTestCase {
|
||||||
var viewModel: InvitesScreenViewModelProtocol!
|
var viewModel: InvitesScreenViewModelProtocol!
|
||||||
var clientProxy: MockClientProxy!
|
var clientProxy: ClientProxyMock!
|
||||||
var userSession: MockUserSession!
|
var userSession: MockUserSession!
|
||||||
var mockNotificationCenter: NotificationCenterMock!
|
var mockNotificationCenter: NotificationCenterMock!
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ class InvitesScreenViewModelTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
clientProxy = MockClientProxy(userID: "@a:b.com")
|
clientProxy = ClientProxyMock(.init(userID: "@a:b.com"))
|
||||||
userSession = MockUserSession(clientProxy: clientProxy,
|
userSession = MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ final class MediaUploadingPreprocessorTests: XCTestCase {
|
|||||||
XCTAssertEqual(audioURL.lastPathComponent, "test_audio.mp3")
|
XCTAssertEqual(audioURL.lastPathComponent, "test_audio.mp3")
|
||||||
|
|
||||||
XCTAssertEqual(audioInfo.mimetype, "audio/mpeg")
|
XCTAssertEqual(audioInfo.mimetype, "audio/mpeg")
|
||||||
XCTAssertEqual(floor(audioInfo.duration ?? 0), 27252)
|
XCTAssertEqual(audioInfo.duration ?? 0, 27252, accuracy: 100)
|
||||||
XCTAssertEqual(audioInfo.size, 764_176)
|
XCTAssertEqual(audioInfo.size ?? 0, 764_176, accuracy: 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLandscapeMovVideoProcessing() async {
|
func testLandscapeMovVideoProcessing() async {
|
||||||
@@ -69,14 +69,14 @@ final class MediaUploadingPreprocessorTests: XCTestCase {
|
|||||||
// Check resulting video info
|
// Check resulting video info
|
||||||
XCTAssertEqual(videoInfo.mimetype, "video/mp4")
|
XCTAssertEqual(videoInfo.mimetype, "video/mp4")
|
||||||
XCTAssertEqual(videoInfo.blurhash, "K22PJZx^DgadWAbbMuRio$")
|
XCTAssertEqual(videoInfo.blurhash, "K22PJZx^DgadWAbbMuRio$")
|
||||||
XCTAssertEqual(videoInfo.size, 1_431_959)
|
XCTAssertEqual(videoInfo.size ?? 0, 1_431_959, accuracy: 100)
|
||||||
XCTAssertEqual(videoInfo.width, 1280)
|
XCTAssertEqual(videoInfo.width, 1280)
|
||||||
XCTAssertEqual(videoInfo.height, 720)
|
XCTAssertEqual(videoInfo.height, 720)
|
||||||
XCTAssertEqual(floor(videoInfo.duration ?? 0), 30483)
|
XCTAssertEqual(videoInfo.duration ?? 0, 30483, accuracy: 100)
|
||||||
|
|
||||||
XCTAssertNotNil(videoInfo.thumbnailInfo)
|
XCTAssertNotNil(videoInfo.thumbnailInfo)
|
||||||
XCTAssertEqual(videoInfo.thumbnailInfo?.mimetype, "image/jpeg")
|
XCTAssertEqual(videoInfo.thumbnailInfo?.mimetype, "image/jpeg")
|
||||||
XCTAssertEqual(videoInfo.thumbnailInfo?.size, 33949)
|
XCTAssertEqual(videoInfo.thumbnailInfo?.size ?? 0, 33949, accuracy: 100)
|
||||||
XCTAssertEqual(videoInfo.thumbnailInfo?.width, 800)
|
XCTAssertEqual(videoInfo.thumbnailInfo?.width, 800)
|
||||||
XCTAssertEqual(videoInfo.thumbnailInfo?.height, 450)
|
XCTAssertEqual(videoInfo.thumbnailInfo?.height, 450)
|
||||||
}
|
}
|
||||||
@@ -109,14 +109,14 @@ final class MediaUploadingPreprocessorTests: XCTestCase {
|
|||||||
// Check resulting video info
|
// Check resulting video info
|
||||||
XCTAssertEqual(videoInfo.mimetype, "video/mp4")
|
XCTAssertEqual(videoInfo.mimetype, "video/mp4")
|
||||||
XCTAssertEqual(videoInfo.blurhash, "K7C$_zt70LKQMx^+~B9GIU")
|
XCTAssertEqual(videoInfo.blurhash, "K7C$_zt70LKQMx^+~B9GIU")
|
||||||
XCTAssertEqual(videoInfo.size, 9_775_822)
|
XCTAssertEqual(videoInfo.size ?? 0, 9_775_822, accuracy: 100)
|
||||||
XCTAssertEqual(videoInfo.width, 1080)
|
XCTAssertEqual(videoInfo.width, 1080)
|
||||||
XCTAssertEqual(videoInfo.height, 1920)
|
XCTAssertEqual(videoInfo.height, 1920)
|
||||||
XCTAssertEqual(floor(videoInfo.duration ?? 0), 21000)
|
XCTAssertEqual(videoInfo.duration ?? 0, 21000, accuracy: 100)
|
||||||
|
|
||||||
XCTAssertNotNil(videoInfo.thumbnailInfo)
|
XCTAssertNotNil(videoInfo.thumbnailInfo)
|
||||||
XCTAssertEqual(videoInfo.thumbnailInfo?.mimetype, "image/jpeg")
|
XCTAssertEqual(videoInfo.thumbnailInfo?.mimetype, "image/jpeg")
|
||||||
XCTAssertEqual(videoInfo.thumbnailInfo?.size, 82854)
|
XCTAssertEqual(videoInfo.thumbnailInfo?.size ?? 0, 82854, accuracy: 100)
|
||||||
XCTAssertEqual(videoInfo.thumbnailInfo?.width, 337)
|
XCTAssertEqual(videoInfo.thumbnailInfo?.width, 337)
|
||||||
XCTAssertEqual(videoInfo.thumbnailInfo?.height, 600)
|
XCTAssertEqual(videoInfo.thumbnailInfo?.height, 600)
|
||||||
}
|
}
|
||||||
@@ -138,13 +138,13 @@ final class MediaUploadingPreprocessorTests: XCTestCase {
|
|||||||
// Check resulting image info
|
// Check resulting image info
|
||||||
XCTAssertEqual(imageInfo.mimetype, "image/jpeg")
|
XCTAssertEqual(imageInfo.mimetype, "image/jpeg")
|
||||||
XCTAssertEqual(imageInfo.blurhash, "K%I#.NofkC_4ayayxujsWB")
|
XCTAssertEqual(imageInfo.blurhash, "K%I#.NofkC_4ayayxujsWB")
|
||||||
XCTAssertEqual(imageInfo.size, 3_305_795)
|
XCTAssertEqual(imageInfo.size ?? 0, 3_305_795, accuracy: 100)
|
||||||
XCTAssertEqual(imageInfo.width, 6103)
|
XCTAssertEqual(imageInfo.width, 6103)
|
||||||
XCTAssertEqual(imageInfo.height, 2621)
|
XCTAssertEqual(imageInfo.height, 2621)
|
||||||
|
|
||||||
XCTAssertNotNil(imageInfo.thumbnailInfo)
|
XCTAssertNotNil(imageInfo.thumbnailInfo)
|
||||||
XCTAssertEqual(imageInfo.thumbnailInfo?.mimetype, "image/jpeg")
|
XCTAssertEqual(imageInfo.thumbnailInfo?.mimetype, "image/jpeg")
|
||||||
XCTAssertEqual(imageInfo.thumbnailInfo?.size, 89553)
|
XCTAssertEqual(imageInfo.thumbnailInfo?.size ?? 0, 89553, accuracy: 100)
|
||||||
XCTAssertEqual(imageInfo.thumbnailInfo?.width, 800)
|
XCTAssertEqual(imageInfo.thumbnailInfo?.width, 800)
|
||||||
XCTAssertEqual(imageInfo.thumbnailInfo?.height, 344)
|
XCTAssertEqual(imageInfo.thumbnailInfo?.height, 344)
|
||||||
}
|
}
|
||||||
@@ -166,13 +166,13 @@ final class MediaUploadingPreprocessorTests: XCTestCase {
|
|||||||
// Check resulting image info
|
// Check resulting image info
|
||||||
XCTAssertEqual(imageInfo.mimetype, "image/jpeg")
|
XCTAssertEqual(imageInfo.mimetype, "image/jpeg")
|
||||||
XCTAssertEqual(imageInfo.blurhash, "KdE:ets+RP^-n*RP%OWAV@")
|
XCTAssertEqual(imageInfo.blurhash, "KdE:ets+RP^-n*RP%OWAV@")
|
||||||
XCTAssertEqual(imageInfo.size, 4_414_666)
|
XCTAssertEqual(imageInfo.size ?? 0, 4_414_666, accuracy: 100)
|
||||||
XCTAssertEqual(imageInfo.width, 3024)
|
XCTAssertEqual(imageInfo.width, 3024)
|
||||||
XCTAssertEqual(imageInfo.height, 4032)
|
XCTAssertEqual(imageInfo.height, 4032)
|
||||||
|
|
||||||
XCTAssertNotNil(imageInfo.thumbnailInfo)
|
XCTAssertNotNil(imageInfo.thumbnailInfo)
|
||||||
XCTAssertEqual(imageInfo.thumbnailInfo?.mimetype, "image/jpeg")
|
XCTAssertEqual(imageInfo.thumbnailInfo?.mimetype, "image/jpeg")
|
||||||
XCTAssertEqual(imageInfo.thumbnailInfo?.size, 264_500)
|
XCTAssertEqual(imageInfo.thumbnailInfo?.size ?? 0, 264_500, accuracy: 100)
|
||||||
XCTAssertEqual(imageInfo.thumbnailInfo?.width, 600)
|
XCTAssertEqual(imageInfo.thumbnailInfo?.width, 600)
|
||||||
XCTAssertEqual(imageInfo.thumbnailInfo?.height, 800)
|
XCTAssertEqual(imageInfo.thumbnailInfo?.height, 800)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import XCTest
|
|||||||
@MainActor
|
@MainActor
|
||||||
final class NotificationManagerTests: XCTestCase {
|
final class NotificationManagerTests: XCTestCase {
|
||||||
var notificationManager: NotificationManager!
|
var notificationManager: NotificationManager!
|
||||||
private let clientProxy = MockClientProxy(userID: "@test:user.net")
|
private let clientProxy = ClientProxyMock(.init(userID: "@test:user.net"))
|
||||||
private lazy var mockUserSession = MockUserSession(clientProxy: clientProxy,
|
private lazy var mockUserSession = MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
@@ -53,7 +53,8 @@ final class NotificationManagerTests: XCTestCase {
|
|||||||
|
|
||||||
func test_whenRegistered_pusherIsCalled() async {
|
func test_whenRegistered_pusherIsCalled() async {
|
||||||
_ = await notificationManager.register(with: Data())
|
_ = await notificationManager.register(with: Data())
|
||||||
XCTAssertTrue(clientProxy.setPusherCalled)
|
|
||||||
|
XCTAssertTrue(clientProxy.setPusherWithCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_whenRegisteredSuccess_completionSuccessIsCalled() async throws {
|
func test_whenRegisteredSuccess_completionSuccessIsCalled() async throws {
|
||||||
@@ -65,7 +66,8 @@ final class NotificationManagerTests: XCTestCase {
|
|||||||
enum TestError: Error {
|
enum TestError: Error {
|
||||||
case someError
|
case someError
|
||||||
}
|
}
|
||||||
clientProxy.setPusherErrorToThrow = TestError.someError
|
|
||||||
|
clientProxy.setPusherWithThrowableError = TestError.someError
|
||||||
let success = await notificationManager.register(with: Data())
|
let success = await notificationManager.register(with: Data())
|
||||||
XCTAssertFalse(success)
|
XCTAssertFalse(success)
|
||||||
}
|
}
|
||||||
@@ -73,13 +75,19 @@ final class NotificationManagerTests: XCTestCase {
|
|||||||
func test_whenRegistered_pusherIsCalledWithCorrectValues() async throws {
|
func test_whenRegistered_pusherIsCalledWithCorrectValues() async throws {
|
||||||
let pushkeyData = Data("1234".utf8)
|
let pushkeyData = Data("1234".utf8)
|
||||||
_ = await notificationManager.register(with: pushkeyData)
|
_ = await notificationManager.register(with: pushkeyData)
|
||||||
XCTAssertEqual(clientProxy.setPusherArgument?.identifiers.pushkey, pushkeyData.base64EncodedString())
|
|
||||||
XCTAssertEqual(clientProxy.setPusherArgument?.identifiers.appId, appSettings.pusherAppId)
|
guard let configuration = clientProxy.setPusherWithReceivedInvocations.first else {
|
||||||
XCTAssertEqual(clientProxy.setPusherArgument?.appDisplayName, "\(InfoPlistReader.main.bundleDisplayName) (iOS)")
|
XCTFail("Invalid pusher configuration sent")
|
||||||
XCTAssertEqual(clientProxy.setPusherArgument?.deviceDisplayName, UIDevice.current.name)
|
return
|
||||||
XCTAssertNotNil(clientProxy.setPusherArgument?.profileTag)
|
}
|
||||||
XCTAssertEqual(clientProxy.setPusherArgument?.lang, Bundle.app.preferredLocalizations.first)
|
|
||||||
guard case let .http(data) = clientProxy.setPusherArgument?.kind else {
|
XCTAssertEqual(configuration.identifiers.pushkey, pushkeyData.base64EncodedString())
|
||||||
|
XCTAssertEqual(configuration.identifiers.appId, appSettings.pusherAppId)
|
||||||
|
XCTAssertEqual(configuration.appDisplayName, "\(InfoPlistReader.main.bundleDisplayName) (iOS)")
|
||||||
|
XCTAssertEqual(configuration.deviceDisplayName, UIDevice.current.name)
|
||||||
|
XCTAssertNotNil(configuration.profileTag)
|
||||||
|
XCTAssertEqual(configuration.lang, Bundle.app.preferredLocalizations.first)
|
||||||
|
guard case let .http(data) = configuration.kind else {
|
||||||
XCTFail("Http kind expected")
|
XCTFail("Http kind expected")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class NotificationSettingsEditScreenViewModelTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@MainActor override func setUpWithError() throws {
|
@MainActor override func setUpWithError() throws {
|
||||||
let clientProxy = MockClientProxy(userID: "@a:b.com")
|
let clientProxy = ClientProxyMock(.init(userID: "@a:b.com"))
|
||||||
userSession = MockUserSession(clientProxy: clientProxy,
|
userSession = MockUserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class RoomFlowCoordinatorTests: XCTestCase {
|
|||||||
|
|
||||||
override func setUp() async throws {
|
override func setUp() async throws {
|
||||||
cancellables.removeAll()
|
cancellables.removeAll()
|
||||||
let clientProxy = MockClientProxy(userID: "hi@bob", roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms)))
|
let clientProxy = ClientProxyMock(.init(userID: "hi@bob", roomSummaryProvider: MockRoomSummaryProvider(state: .loaded(.mockRooms))))
|
||||||
let mediaProvider = MockMediaProvider()
|
let mediaProvider = MockMediaProvider()
|
||||||
let voiceMessageMediaManager = VoiceMessageMediaManagerMock()
|
let voiceMessageMediaManager = VoiceMessageMediaManagerMock()
|
||||||
let userSession = MockUserSession(clientProxy: clientProxy,
|
let userSession = MockUserSession(clientProxy: clientProxy,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class SettingsScreenViewModelTests: XCTestCase {
|
|||||||
|
|
||||||
@MainActor override func setUpWithError() throws {
|
@MainActor override func setUpWithError() throws {
|
||||||
cancellables.removeAll()
|
cancellables.removeAll()
|
||||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: ""),
|
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||||
viewModel = SettingsScreenViewModel(userSession: userSession, appSettings: ServiceLocator.shared.settings)
|
viewModel = SettingsScreenViewModel(userSession: userSession, appSettings: ServiceLocator.shared.settings)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import XCTest
|
|||||||
@MainActor
|
@MainActor
|
||||||
class StartChatScreenViewModelTests: XCTestCase {
|
class StartChatScreenViewModelTests: XCTestCase {
|
||||||
var viewModel: StartChatScreenViewModelProtocol!
|
var viewModel: StartChatScreenViewModelProtocol!
|
||||||
var clientProxy: MockClientProxy!
|
var clientProxy: ClientProxyMock!
|
||||||
var userDiscoveryService: UserDiscoveryServiceMock!
|
var userDiscoveryService: UserDiscoveryServiceMock!
|
||||||
|
|
||||||
var context: StartChatScreenViewModel.Context {
|
var context: StartChatScreenViewModel.Context {
|
||||||
@@ -29,7 +29,7 @@ class StartChatScreenViewModelTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
clientProxy = .init(userID: "")
|
clientProxy = .init(.init(userID: ""))
|
||||||
userDiscoveryService = UserDiscoveryServiceMock()
|
userDiscoveryService = UserDiscoveryServiceMock()
|
||||||
userDiscoveryService.fetchSuggestionsReturnValue = .success([])
|
userDiscoveryService.fetchSuggestionsReturnValue = .success([])
|
||||||
userDiscoveryService.searchProfilesWithReturnValue = .success([])
|
userDiscoveryService.searchProfilesWithReturnValue = .success([])
|
||||||
|
|||||||
@@ -21,68 +21,68 @@ import XCTest
|
|||||||
@MainActor
|
@MainActor
|
||||||
class UserDiscoveryServiceTest: XCTestCase {
|
class UserDiscoveryServiceTest: XCTestCase {
|
||||||
var service: UserDiscoveryService!
|
var service: UserDiscoveryService!
|
||||||
var clientProxy: MockClientProxy!
|
var clientProxy: ClientProxyMock!
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
clientProxy = .init(userID: "@foo:matrix.org")
|
clientProxy = .init(.init(userID: "@foo:matrix.org"))
|
||||||
service = UserDiscoveryService(clientProxy: clientProxy)
|
service = UserDiscoveryService(clientProxy: clientProxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testQueryShowingResults() async throws {
|
func testQueryShowingResults() async throws {
|
||||||
clientProxy.searchUsersResult = .success(.init(results: [UserProfileProxy.mockAlice], limited: true))
|
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: [UserProfileProxy.mockAlice], limited: true))
|
||||||
|
|
||||||
let results = await (try? search(query: "AAA").get()) ?? []
|
let results = await (try? search(query: "AAA").get()) ?? []
|
||||||
assertSearchResults(results, toBe: 1)
|
assertSearchResults(results, toBe: 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testOwnerIsFiltered() async throws {
|
func testOwnerIsFiltered() async throws {
|
||||||
clientProxy.searchUsersResult = .success(.init(results: [UserProfileProxy(userID: "@foo:matrix.org")], limited: true))
|
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: [UserProfileProxy(userID: "@foo:matrix.org")], limited: true))
|
||||||
|
|
||||||
let results = await (try? search(query: "AAA").get()) ?? []
|
let results = await (try? search(query: "AAA").get()) ?? []
|
||||||
assertSearchResults(results, toBe: 0)
|
assertSearchResults(results, toBe: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetProfileIsNotCalled() async {
|
func testGetProfileIsNotCalled() async {
|
||||||
clientProxy.searchUsersResult = .success(.init(results: searchResults, limited: true))
|
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: searchResults, limited: true))
|
||||||
clientProxy.getProfileResult = .success(.init(userID: "@alice:matrix.org"))
|
clientProxy.profileForReturnValue = .success(.init(userID: "@alice:matrix.org"))
|
||||||
|
|
||||||
let results = await (try? search(query: "AAA").get()) ?? []
|
let results = await (try? search(query: "AAA").get()) ?? []
|
||||||
assertSearchResults(results, toBe: 3)
|
assertSearchResults(results, toBe: 3)
|
||||||
XCTAssertFalse(clientProxy.getProfileCalled)
|
XCTAssertFalse(clientProxy.profileForCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetProfileIsNotCalledForAccountOwnerID() async {
|
func testGetProfileIsNotCalledForAccountOwnerID() async {
|
||||||
clientProxy.searchUsersResult = .success(.init(results: searchResults, limited: true))
|
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: searchResults, limited: true))
|
||||||
clientProxy.getProfileResult = .success(.init(userID: "@alice:matrix.org"))
|
clientProxy.profileForReturnValue = .success(.init(userID: "@alice:matrix.org"))
|
||||||
|
|
||||||
let results = await (try? search(query: "foo:matrix.org").get()) ?? []
|
let results = await (try? search(query: "foo:matrix.org").get()) ?? []
|
||||||
assertSearchResults(results, toBe: 3)
|
assertSearchResults(results, toBe: 3)
|
||||||
XCTAssertFalse(clientProxy.getProfileCalled)
|
XCTAssertFalse(clientProxy.profileForCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLocalResultShows() async {
|
func testLocalResultShows() async {
|
||||||
clientProxy.searchUsersResult = .success(.init(results: searchResults, limited: true))
|
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: searchResults, limited: true))
|
||||||
clientProxy.getProfileResult = .success(.init(userID: "@some:matrix.org"))
|
clientProxy.profileForReturnValue = .success(.init(userID: "@some:matrix.org"))
|
||||||
|
|
||||||
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
||||||
|
|
||||||
assertSearchResults(results, toBe: 4)
|
assertSearchResults(results, toBe: 4)
|
||||||
XCTAssertTrue(clientProxy.getProfileCalled)
|
XCTAssertTrue(clientProxy.profileForCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLocalResultShowsOnSearchError() async {
|
func testLocalResultShowsOnSearchError() async {
|
||||||
clientProxy.searchUsersResult = .failure(.failedSearchingUsers)
|
clientProxy.searchUsersSearchTermLimitReturnValue = .failure(.failedSearchingUsers)
|
||||||
clientProxy.getProfileResult = .success(.init(userID: "@some:matrix.org"))
|
clientProxy.profileForReturnValue = .success(.init(userID: "@some:matrix.org"))
|
||||||
|
|
||||||
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
||||||
|
|
||||||
assertSearchResults(results, toBe: 1)
|
assertSearchResults(results, toBe: 1)
|
||||||
XCTAssertTrue(clientProxy.getProfileCalled)
|
XCTAssertTrue(clientProxy.profileForCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSearchErrorTriggers() async {
|
func testSearchErrorTriggers() async {
|
||||||
clientProxy.searchUsersResult = .failure(.failedSearchingUsers)
|
clientProxy.searchUsersSearchTermLimitReturnValue = .failure(.failedSearchingUsers)
|
||||||
clientProxy.getProfileResult = .success(.init(userID: "@some:matrix.org"))
|
clientProxy.profileForReturnValue = .success(.init(userID: "@some:matrix.org"))
|
||||||
|
|
||||||
switch await search(query: "some query") {
|
switch await search(query: "some query") {
|
||||||
case .success:
|
case .success:
|
||||||
@@ -91,30 +91,30 @@ class UserDiscoveryServiceTest: XCTestCase {
|
|||||||
XCTAssertEqual(error, UserDiscoveryErrorType.failedSearchingUsers)
|
XCTAssertEqual(error, UserDiscoveryErrorType.failedSearchingUsers)
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertFalse(clientProxy.getProfileCalled)
|
XCTAssertFalse(clientProxy.profileForCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLocalResultWithDuplicates() async {
|
func testLocalResultWithDuplicates() async {
|
||||||
clientProxy.searchUsersResult = .success(.init(results: searchResults, limited: true))
|
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: searchResults, limited: true))
|
||||||
clientProxy.getProfileResult = .success(.init(userID: "@bob:matrix.org"))
|
clientProxy.profileForReturnValue = .success(.init(userID: "@bob:matrix.org"))
|
||||||
|
|
||||||
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
||||||
|
|
||||||
assertSearchResults(results, toBe: 3)
|
assertSearchResults(results, toBe: 3)
|
||||||
let firstUserID = results.first?.userID
|
let firstUserID = results.first?.userID
|
||||||
XCTAssertEqual(firstUserID, "@bob:matrix.org")
|
XCTAssertEqual(firstUserID, "@bob:matrix.org")
|
||||||
XCTAssertTrue(clientProxy.getProfileCalled)
|
XCTAssertTrue(clientProxy.profileForCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSearchResultsShowWhenGetProfileFails() async {
|
func testSearchResultsShowWhenGetProfileFails() async {
|
||||||
clientProxy.searchUsersResult = .success(.init(results: searchResults, limited: true))
|
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: searchResults, limited: true))
|
||||||
clientProxy.getProfileResult = .failure(.failedGettingUserProfile)
|
clientProxy.profileForReturnValue = .failure(.failedGettingUserProfile)
|
||||||
|
|
||||||
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
||||||
|
|
||||||
let firstUserID = results.first?.userID
|
let firstUserID = results.first?.userID
|
||||||
XCTAssertEqual(firstUserID, "@a:b.com")
|
XCTAssertEqual(firstUserID, "@a:b.com")
|
||||||
XCTAssertTrue(clientProxy.getProfileCalled)
|
XCTAssertTrue(clientProxy.profileForCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|||||||
@@ -19,11 +19,15 @@ import XCTest
|
|||||||
|
|
||||||
final class UserSessionTests: XCTestCase {
|
final class UserSessionTests: XCTestCase {
|
||||||
var userSession: UserSession!
|
var userSession: UserSession!
|
||||||
let clientProxy = MockClientProxy(userID: "@test:user.net")
|
var clientProxy: ClientProxyMock!
|
||||||
|
let actionsPublisher = PassthroughSubject<ClientProxyAction, Never>()
|
||||||
|
|
||||||
private var cancellables = Set<AnyCancellable>()
|
private var cancellables = Set<AnyCancellable>()
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
|
clientProxy = ClientProxyMock(.init(userID: "@test:user.net"))
|
||||||
|
clientProxy.actionsPublisher = actionsPublisher.eraseToAnyPublisher()
|
||||||
|
|
||||||
cancellables.removeAll()
|
cancellables.removeAll()
|
||||||
userSession = UserSession(clientProxy: clientProxy,
|
userSession = UserSession(clientProxy: clientProxy,
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
@@ -42,8 +46,11 @@ final class UserSessionTests: XCTestCase {
|
|||||||
let controller = SessionVerificationControllerProxyMock.configureMock(callbacks: PassthroughSubject<SessionVerificationControllerProxyCallback, Never>(),
|
let controller = SessionVerificationControllerProxyMock.configureMock(callbacks: PassthroughSubject<SessionVerificationControllerProxyCallback, Never>(),
|
||||||
isVerified: false,
|
isVerified: false,
|
||||||
requestDelay: .zero)
|
requestDelay: .zero)
|
||||||
clientProxy.sessionVerificationControllerProxyResult = .success(controller)
|
|
||||||
clientProxy.actionsSubject.send(.receivedSyncUpdate)
|
clientProxy.sessionVerificationControllerProxyReturnValue = .success(controller)
|
||||||
|
|
||||||
|
actionsPublisher.send(.receivedSyncUpdate)
|
||||||
|
|
||||||
waitForExpectations(timeout: 1.0)
|
waitForExpectations(timeout: 1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +59,7 @@ final class UserSessionTests: XCTestCase {
|
|||||||
let controller = SessionVerificationControllerProxyMock.configureMock(callbacks: PassthroughSubject<SessionVerificationControllerProxyCallback, Never>(),
|
let controller = SessionVerificationControllerProxyMock.configureMock(callbacks: PassthroughSubject<SessionVerificationControllerProxyCallback, Never>(),
|
||||||
isVerified: false,
|
isVerified: false,
|
||||||
requestDelay: .zero)
|
requestDelay: .zero)
|
||||||
clientProxy.sessionVerificationControllerProxyResult = .success(controller)
|
clientProxy.sessionVerificationControllerProxyReturnValue = .success(controller)
|
||||||
|
|
||||||
controller.callbacks.sink { value in
|
controller.callbacks.sink { value in
|
||||||
switch value {
|
switch value {
|
||||||
@@ -64,7 +71,7 @@ final class UserSessionTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
clientProxy.actionsSubject.send(.receivedSyncUpdate)
|
actionsPublisher.send(.receivedSyncUpdate)
|
||||||
controller.callbacks.send(.finished)
|
controller.callbacks.send(.finished)
|
||||||
waitForExpectations(timeout: 1.0)
|
waitForExpectations(timeout: 1.0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class WaitlistScreenViewModelTests: XCTestCase {
|
|||||||
XCTAssertNil(context.viewState.userSession, "No user session should be set on a new view model.")
|
XCTAssertNil(context.viewState.userSession, "No user session should be set on a new view model.")
|
||||||
XCTAssertTrue(context.viewState.isWaiting, "The view should start off in the waiting state.")
|
XCTAssertTrue(context.viewState.isWaiting, "The view should start off in the waiting state.")
|
||||||
|
|
||||||
viewModel.update(userSession: MockUserSession(clientProxy: MockClientProxy(userID: "@alice:matrix.org"),
|
viewModel.update(userSession: MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@alice:matrix.org")),
|
||||||
mediaProvider: MockMediaProvider(),
|
mediaProvider: MockMediaProvider(),
|
||||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock()))
|
voiceMessageMediaManager: VoiceMessageMediaManagerMock()))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user