diff --git a/.github/workflows/ci-crypto-tests.yml b/.github/workflows/ci-crypto-tests.yml index 6b932b73b6..60bc264fa3 100644 --- a/.github/workflows/ci-crypto-tests.yml +++ b/.github/workflows/ci-crypto-tests.yml @@ -36,7 +36,6 @@ jobs: restore-keys: | ${{ runner.os }}-pip- ${{ runner.os }}- - # Cache for Xcode env - uses: actions/cache@v2 with: @@ -50,7 +49,6 @@ jobs: key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} restore-keys: | ${{ runner.os }}-gems- - - name: Start synapse server uses: michaelkaye/setup-matrix-synapse@v1.0.3 with: @@ -62,21 +60,27 @@ jobs: run: | bundle config path vendor/bundle bundle install --jobs 4 --retry 3 - # Main step - name: Crypto tests run: bundle exec fastlane test testplan:CryptoTests # Store artifacts - uses: actions/upload-artifact@v2 + if: always() with: name: report.html path: build/test/report.html - uses: actions/upload-artifact@v2 + if: always() with: name: report.junit path: build/test/report.junit - uses: actions/upload-artifact@v2 + if: always() with: name: MatrixSDK-macOS.xcresult path: build/test/MatrixSDK-macOS.xcresult/ + + # Upload coverage + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/.github/workflows/ci-integration-tests.yml b/.github/workflows/ci-integration-tests.yml new file mode 100644 index 0000000000..694840f7f3 --- /dev/null +++ b/.github/workflows/ci-integration-tests.yml @@ -0,0 +1,91 @@ +name: Integration Tests CI + +on: + # Triggers the workflow on any pull request and push to develop + push: + branches: [ develop ] + pull_request: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + integration-tests: + name: Integration Tests + runs-on: macos-11 + + concurrency: + # When running on develop, use the sha to allow all runs of this workflow to run concurrently. + # Otherwise only allow a single run of this workflow on each branch, automatically cancelling older runs. + group: ${{ github.ref == 'refs/heads/develop' && format('tests-integration-develop-{0}', github.sha) || format('tests-integration-{0}', github.ref) }} + cancel-in-progress: true + + steps: + - uses: actions/checkout@v2 + + # Common cache + # Note: GH actions do not support yaml anchor yet. We need to duplicate this for every job + - uses: actions/cache@v2 + with: + path: Pods + key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + - uses: actions/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + # Cache for python env for Synapse + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip + restore-keys: | + ${{ runner.os }}-pip- + ${{ runner.os }}- + + # Set up a Synapse server + - name: Start synapse server + uses: michaelkaye/setup-matrix-synapse@v1.0.3 + with: + uploadLogs: true + httpPort: 8080 + disableRateLimiting: true + + # Common setup + # Note: GH actions do not support yaml anchor yet. We need to duplicate this for every job + - name: Bundle install + run: | + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + # Main step + - name: Integration tests + run: bundle exec fastlane test testplan:AllWorkingTests + + # Store artifacts + - uses: actions/upload-artifact@v2 + if: always() + with: + name: report.html + path: build/test/report.html + - uses: actions/upload-artifact@v2 + if: always() + with: + name: report.junit + path: build/test/report.junit + - uses: actions/upload-artifact@v2 + if: always() + with: + name: MatrixSDK-macOS.xcresult + path: build/test/MatrixSDK-macOS.xcresult/ + + # Upload coverage + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore index 073a66b0e7..eba5c0bd71 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,8 @@ DerivedData *.ipa *.xcuserstate *.DS_Store +.vscode/ +vendor/ # CocoaPods # diff --git a/CHANGES.md b/CHANGES.md index 8a6c585b89..219b1c407e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,17 @@ +## Changes in 0.23.14 (2022-08-09) + +🙌 Improvements + +- CI: Enable integration tests on GitHub actions ([#1537](https://github.com/matrix-org/matrix-ios-sdk/pull/1537)) +- App Layout: Added breadcrumbs data fetcher and updated room summary data type to reflect new needs ([#6407](https://github.com/vector-im/element-ios/issues/6407)) +- App Layout: added MXSpace.minimumPowerLevelForAddingRoom() and MXSpaceService.rootSpaces ([#6410](https://github.com/vector-im/element-ios/issues/6410)) + +🐛 Bugfixes + +- MXRestClient: Send an empty dictionary when calling /join to be spec compliant. ([#6481](https://github.com/vector-im/element-ios/issues/6481)) +- App Layout: exclude room summaries without notifications from unread list ([#6511](https://github.com/vector-im/element-ios/issues/6511)) + + ## Changes in 0.23.13 (2022-07-26) 🙌 Improvements diff --git a/MatrixSDK.podspec b/MatrixSDK.podspec index 28ed3f5739..246e372012 100644 --- a/MatrixSDK.podspec +++ b/MatrixSDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MatrixSDK" - s.version = "0.23.13" + s.version = "0.23.14" s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)" s.description = <<-DESC diff --git a/MatrixSDK.xcodeproj/project.pbxproj b/MatrixSDK.xcodeproj/project.pbxproj index 8a28c5e2c4..88b2d6d746 100644 --- a/MatrixSDK.xcodeproj/project.pbxproj +++ b/MatrixSDK.xcodeproj/project.pbxproj @@ -315,6 +315,8 @@ 32618E7220ED2DF500E1D2EA /* MXFilterJSONModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 32618E7020ED2DF500E1D2EA /* MXFilterJSONModel.m */; }; 32618E7B20EFA45B00E1D2EA /* MXRoomMembers.h in Headers */ = {isa = PBXBuildFile; fileRef = 32618E7920EFA45B00E1D2EA /* MXRoomMembers.h */; settings = {ATTRIBUTES = (Public, ); }; }; 32618E7C20EFA45B00E1D2EA /* MXRoomMembers.m in Sources */ = {isa = PBXBuildFile; fileRef = 32618E7A20EFA45B00E1D2EA /* MXRoomMembers.m */; }; + 326277F1288BC21A009A0508 /* AllWorkingTests.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 326277F0288BC219009A0508 /* AllWorkingTests.xctestplan */; }; + 326277F2288BC21A009A0508 /* AllWorkingTests.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 326277F0288BC219009A0508 /* AllWorkingTests.xctestplan */; }; 32637ED41E5B00400011E20D /* MXDeviceList.h in Headers */ = {isa = PBXBuildFile; fileRef = 32637ED21E5B00400011E20D /* MXDeviceList.h */; }; 32637ED51E5B00400011E20D /* MXDeviceList.m in Sources */ = {isa = PBXBuildFile; fileRef = 32637ED31E5B00400011E20D /* MXDeviceList.m */; }; 3264DB911CEC528D00B99881 /* MXAccountData.h in Headers */ = {isa = PBXBuildFile; fileRef = 3264DB8F1CEC528D00B99881 /* MXAccountData.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -673,6 +675,8 @@ 3A23A740256D322C00B9D00F /* MXAes.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A23A73D256D322C00B9D00F /* MXAes.m */; }; 3A23A741256D322C00B9D00F /* MXAes.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A23A73E256D322C00B9D00F /* MXAes.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3A23A742256D322C00B9D00F /* MXAes.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A23A73E256D322C00B9D00F /* MXAes.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3A5787A528982D4600A0D8A8 /* MXBreadcrumbsRoomListDataFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A5787A428982D4600A0D8A8 /* MXBreadcrumbsRoomListDataFetcher.swift */; }; + 3A5787A628982D4600A0D8A8 /* MXBreadcrumbsRoomListDataFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A5787A428982D4600A0D8A8 /* MXBreadcrumbsRoomListDataFetcher.swift */; }; 3A59A49D25A7A16F00DDA1FC /* MXOlmOutboundGroupSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A59A49B25A7A16E00DDA1FC /* MXOlmOutboundGroupSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3A59A49E25A7A16F00DDA1FC /* MXOlmOutboundGroupSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A59A49B25A7A16E00DDA1FC /* MXOlmOutboundGroupSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3A59A49F25A7A16F00DDA1FC /* MXOlmOutboundGroupSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A59A49C25A7A16F00DDA1FC /* MXOlmOutboundGroupSession.m */; }; @@ -2117,6 +2121,7 @@ 32618E7020ED2DF500E1D2EA /* MXFilterJSONModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXFilterJSONModel.m; sourceTree = ""; }; 32618E7920EFA45B00E1D2EA /* MXRoomMembers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXRoomMembers.h; sourceTree = ""; }; 32618E7A20EFA45B00E1D2EA /* MXRoomMembers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXRoomMembers.m; sourceTree = ""; }; + 326277F0288BC219009A0508 /* AllWorkingTests.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AllWorkingTests.xctestplan; sourceTree = ""; }; 32637ED21E5B00400011E20D /* MXDeviceList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXDeviceList.h; sourceTree = ""; }; 32637ED31E5B00400011E20D /* MXDeviceList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXDeviceList.m; sourceTree = ""; }; 3264DB8F1CEC528D00B99881 /* MXAccountData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXAccountData.h; sourceTree = ""; }; @@ -2419,6 +2424,7 @@ 3A108E6625826F52005EEBE9 /* MXKeyProviderUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXKeyProviderUnitTests.m; sourceTree = ""; }; 3A23A73D256D322C00B9D00F /* MXAes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXAes.m; sourceTree = ""; }; 3A23A73E256D322C00B9D00F /* MXAes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXAes.h; sourceTree = ""; }; + 3A5787A428982D4600A0D8A8 /* MXBreadcrumbsRoomListDataFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MXBreadcrumbsRoomListDataFetcher.swift; sourceTree = ""; }; 3A59A49B25A7A16E00DDA1FC /* MXOlmOutboundGroupSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXOlmOutboundGroupSession.h; sourceTree = ""; }; 3A59A49C25A7A16F00DDA1FC /* MXOlmOutboundGroupSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXOlmOutboundGroupSession.m; sourceTree = ""; }; 3A59A52725A7B1B000DDA1FC /* MXOutboundSessionInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXOutboundSessionInfo.h; sourceTree = ""; }; @@ -3742,6 +3748,7 @@ 3298ABD42637FA3100E40B06 /* TestPlans */ = { isa = PBXGroup; children = ( + 326277F0288BC219009A0508 /* AllWorkingTests.xctestplan */, 3298ABD52637FA3100E40B06 /* AllTests.xctestplan */, 3209682F26396385005D64ED /* AllTestsWithSanitizers.xctestplan */, EDC2A0E528369E740039F3D6 /* CryptoTests.xctestplan */, @@ -4688,6 +4695,7 @@ EC1165A927107E330089FA56 /* MXSuggestedRoomListDataCache.swift */, EC0B941D27186C3500B4D440 /* MXRoomListDataSortable.swift */, EC0B942027186D4600B4D440 /* MXRoomListDataFilterable.swift */, + 3A5787A428982D4600A0D8A8 /* MXBreadcrumbsRoomListDataFetcher.swift */, ); path = Common; sourceTree = ""; @@ -5982,6 +5990,7 @@ buildActionMask = 2147483647; files = ( 3298ABD62637FA3100E40B06 /* AllTests.xctestplan in Resources */, + 326277F1288BC21A009A0508 /* AllWorkingTests.xctestplan in Resources */, 3209683326396385005D64ED /* UnitTestsWithSanitizers.xctestplan in Resources */, 3298ABDD2637FB1900E40B06 /* UnitTests.xctestplan in Resources */, 3209683126396385005D64ED /* AllTestsWithSanitizers.xctestplan in Resources */, @@ -6001,6 +6010,7 @@ buildActionMask = 2147483647; files = ( 3298ABD72637FA3100E40B06 /* AllTests.xctestplan in Resources */, + 326277F2288BC21A009A0508 /* AllWorkingTests.xctestplan in Resources */, 3209683426396385005D64ED /* UnitTestsWithSanitizers.xctestplan in Resources */, 3298ABDE2637FB1900E40B06 /* UnitTests.xctestplan in Resources */, 3209683226396385005D64ED /* AllTestsWithSanitizers.xctestplan in Resources */, @@ -6141,6 +6151,7 @@ 32B76EA520FDE85100B095F6 /* MXRoomMembersCount.m in Sources */, 3AD4F231274B922D003F47FE /* MXRoomAliasAvailabilityChecker.swift in Sources */, B1710B1F2613D01400A9B429 /* MXSpaceChildrenRequestParameters.swift in Sources */, + 3A5787A528982D4600A0D8A8 /* MXBreadcrumbsRoomListDataFetcher.swift in Sources */, 32CEEF4B23B0A8170039BA98 /* MXCrossSigningTools.m in Sources */, EC8A53A525B1BC77004E0802 /* MXCallInviteEventContent.m in Sources */, 323F877D25546170009E9E67 /* MXBaseProfiler.m in Sources */, @@ -6709,6 +6720,7 @@ B16C56E3261D0A9D00604765 /* MXSpaceChildInfo.swift in Sources */, 3AD4F232274B922D003F47FE /* MXRoomAliasAvailabilityChecker.swift in Sources */, B14EF1D52397E90400758AF0 /* MXEventAnnotation.m in Sources */, + 3A5787A628982D4600A0D8A8 /* MXBreadcrumbsRoomListDataFetcher.swift in Sources */, B14EF1D62397E90400758AF0 /* MXPusher.m in Sources */, B14EF1D72397E90400758AF0 /* MXMediaLoader.m in Sources */, 32549AF823F2E2790002576B /* MXKeyVerificationReady.m in Sources */, diff --git a/MatrixSDK.xcodeproj/xcshareddata/xcschemes/MatrixSDK-macOS.xcscheme b/MatrixSDK.xcodeproj/xcshareddata/xcschemes/MatrixSDK-macOS.xcscheme index f490df4721..bdf6494136 100644 --- a/MatrixSDK.xcodeproj/xcshareddata/xcschemes/MatrixSDK-macOS.xcscheme +++ b/MatrixSDK.xcodeproj/xcshareddata/xcschemes/MatrixSDK-macOS.xcscheme @@ -67,6 +67,9 @@ + + = MXMulticastDelegate() + + var data: MXRoomListData? { + didSet { + guard data != nil else { + // do not notify when stopped + return + } + + notifyDataChange() + } + } + + internal init(fetchOptions: MXRoomListDataFetchOptions, + session: MXSession?) { + self.fetchOptions = fetchOptions + self.session = session + super.init() + self.fetchOptions.fetcher = self + self.refresh() + self.addDataObservers() + } + + // MARK: - Delegate + + func addDelegate(_ delegate: MXRoomListDataFetcherDelegate) { + multicastDelegate.addDelegate(delegate) + } + + func removeDelegate(_ delegate: MXRoomListDataFetcherDelegate) { + multicastDelegate.removeDelegate(delegate) + } + + func removeAllDelegates() { + multicastDelegate.removeAllDelegates() + } + + internal func notifyDataChange() { + multicastDelegate.invoke({ $0.fetcherDidChangeData(self, totalCountsChanged: true) }) + } + + func paginate() { + // Do nothing. We don't paginate breadcrumbs + } + + func resetPagination() { + // Do nothing. We don't paginate breadcrumbs + } + + // MARK: - Public + + func refresh() { + guard let breadcrumbs = session?.accountData?.accountData(forEventType: kMXAccountDataTypeBreadcrumbs) as? [AnyHashable: [String]] else { + MXLog.warning("[MXBreadcrumbsRoomListDataFetcher] cannot retrieve breadcrumbs") + return + } + + guard var recentRoomIds = breadcrumbs[kMXAccountDataTypeRecentRoomsKey] else { + MXLog.warning("[MXBreadcrumbsRoomListDataFetcher] cannot retrieve recent rooms") + return + } + + if let query = fetchOptions.filterOptions.query?.lowercased(), !query.isEmpty { + recentRoomIds = recentRoomIds.filter({ roomId in + guard let summary = session?.roomSummary(withRoomId: roomId) else { + return false + } + return summary.displayname.lowercased().contains(query) + }) + } + + guard self.recentRoomIds != recentRoomIds else { + // Nothing to do then + return + } + + let summaries: [MXRoomSummary] = recentRoomIds.compactMap { + guard let summary = session?.roomSummary(withRoomId: $0), summary.roomType == .room else { + return nil + } + return summary + } + + var total: MXRoomListDataCounts? + if !summaries.isEmpty { + // compute total counts just before cutting the rooms array + total = MXStoreRoomListDataCounts(withRooms: summaries, total: nil) + } + + self.data = MXRoomListData(rooms: summaries, + counts: MXStoreRoomListDataCounts(withRooms: summaries, + total: total), + paginationOptions: fetchOptions.paginationOptions) + self.recentRoomIds = recentRoomIds + } + + func stop() { + removeAllDelegates() + removeDataObservers() + data = nil + recentRoomIds = [] + } + + // MARK: - Data observers + + func addDataObservers() { + sessionSyncObserver = NotificationCenter.default.addObserver(forName:NSNotification.Name.mxSessionAccountDataDidChangeBreadcrumbs, object:session, queue:OperationQueue.main) { [weak self] (_) in + guard let self = self else { return } + + self.refresh() + } + } + + func removeDataObservers() { + if let sessionSyncObserver = sessionSyncObserver { + NotificationCenter.default.removeObserver(sessionSyncObserver) + } + } + +} diff --git a/MatrixSDK/Data/RoomList/Common/MXRoomListDataSortable.swift b/MatrixSDK/Data/RoomList/Common/MXRoomListDataSortable.swift index ab696b3fe9..65a1f4a10b 100644 --- a/MatrixSDK/Data/RoomList/Common/MXRoomListDataSortable.swift +++ b/MatrixSDK/Data/RoomList/Common/MXRoomListDataSortable.swift @@ -51,6 +51,10 @@ extension MXRoomListDataSortable { // result.append(NSSortDescriptor(keyPath: \MXRoomSummaryProtocol.spaceChildInfo?.order, ascending: false)) // } + if sortOptions.alphabetical { + result.append(NSSortDescriptor(keyPath: \MXRoomSummaryProtocol.displayname, ascending: true)) + } + if sortOptions.invitesFirst { result.append(NSSortDescriptor(keyPath: \MXRoomSummaryProtocol.membership, ascending: true)) } diff --git a/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataFetcher.swift b/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataFetcher.swift index b253073735..c5b0189e6c 100644 --- a/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataFetcher.swift +++ b/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataFetcher.swift @@ -252,6 +252,10 @@ extension MXCoreDataRoomListDataFetcher: MXRoomListDataSortable { func sortDescriptors(for sortOptions: MXRoomListDataSortOptions) -> [NSSortDescriptor] { var result: [NSSortDescriptor] = [] + if sortOptions.alphabetical { + result.append(NSSortDescriptor(keyPath: \MXRoomSummaryMO.s_displayName, ascending: true)) + } + if sortOptions.invitesFirst { result.append(NSSortDescriptor(keyPath: \MXRoomSummaryMO.s_membershipInt, ascending: true)) } diff --git a/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataManager.swift b/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataManager.swift index 1846e6ca31..1fa441a57a 100644 --- a/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataManager.swift +++ b/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataManager.swift @@ -36,6 +36,9 @@ public class MXCoreDataRoomListDataManager: NSObject, MXRoomListDataManager { session: session, spaceService: spaceService) } + if options.filterOptions.onlyBreadcrumbs { + return MXBreadcrumbsRoomListDataFetcher(fetchOptions: options, session: session) + } guard let store = session?.store else { fatalError("[MXCoreDataRoomListDataManager] No session store") } diff --git a/MatrixSDK/Data/RoomList/MXRoomListDataFilterOptions.swift b/MatrixSDK/Data/RoomList/MXRoomListDataFilterOptions.swift index d3bff5d1b2..83377d3afa 100644 --- a/MatrixSDK/Data/RoomList/MXRoomListDataFilterOptions.swift +++ b/MatrixSDK/Data/RoomList/MXRoomListDataFilterOptions.swift @@ -47,11 +47,15 @@ public struct MXRoomListDataFilterOptions: Equatable { /// Flag to show only rooms that matches all the provided `dataTypes`. This has no effect when `onlySuggested` is `true` public let strictMatches: Bool + ///Flag to fetch and order rooms according room IDs stored in the `im.vector.setting.breadcrumbs` event within the user account data. + public let onlyBreadcrumbs: Bool + /// Initializer /// - Parameters: /// - dataTypes: data types to fetch. Pass `MXRoomListDataFilterOptions.emptyDataTypes` not to specify any. /// - notDataTypes: data types not to fetch. Pass `MXRoomListDataFilterOptions.emptyDataTypes` not to specify any. /// - onlySuggested: flag to filter only suggested rooms. Only `space` and `query` parameters are honored if true. + /// - onlyBreadcrumbs: flag to fetch and order rooms according room IDs stored in the `im.vector.setting.breadcrumbs` event within the user account data. /// - query: search query /// - space: active space /// - showAllRoomsInHomeSpace: flag to show all rooms in home space (when `space` is not provided) @@ -60,6 +64,7 @@ public struct MXRoomListDataFilterOptions: Equatable { public init(dataTypes: MXRoomSummaryDataTypes = MXRoomListDataFilterOptions.emptyDataTypes, notDataTypes: MXRoomSummaryDataTypes = [.hidden, .conferenceUser, .space], onlySuggested: Bool = false, + onlyBreadcrumbs: Bool = false, query: String? = nil, space: MXSpace? = nil, showAllRoomsInHomeSpace: Bool, @@ -68,6 +73,7 @@ public struct MXRoomListDataFilterOptions: Equatable { self.dataTypes = dataTypes self.notDataTypes = notDataTypes self.onlySuggested = onlySuggested + self.onlyBreadcrumbs = onlyBreadcrumbs self.query = query self.space = space self.showAllRoomsInHomeSpace = showAllRoomsInHomeSpace diff --git a/MatrixSDK/Data/RoomList/MXRoomListDataSortOptions.swift b/MatrixSDK/Data/RoomList/MXRoomListDataSortOptions.swift index c790e45e51..8d3a43a102 100644 --- a/MatrixSDK/Data/RoomList/MXRoomListDataSortOptions.swift +++ b/MatrixSDK/Data/RoomList/MXRoomListDataSortOptions.swift @@ -47,10 +47,17 @@ public struct MXRoomListDataSortOptions: Equatable { /// Related fetcher will be refreshed automatically when updated. public var unreadMessagesFirst: Bool + /// Flag to sort rooms alphabetically. + /// Related fetcher will be refreshed automatically when updated. + public var alphabetical: Bool + /// Initializer /// - Parameters: /// - sentStatus: flag to sort by sent status /// - lastEventDate: flag to sort by last event date + /// - favoriteTag: Flag to sort by favorite tag order + /// - suggested: Flag to sort by suggested room flag + /// - alphabetical: Flag to sort rooms alphabetically /// - missedNotificationsFirst: flag to sort by missed notification count /// - unreadMessagesFirst: flag to sort by unread count public init(invitesFirst: Bool = true, @@ -58,6 +65,7 @@ public struct MXRoomListDataSortOptions: Equatable { lastEventDate: Bool = true, favoriteTag: Bool = false, suggested: Bool = true, + alphabetical: Bool = false, missedNotificationsFirst: Bool, unreadMessagesFirst: Bool) { self.invitesFirst = invitesFirst @@ -65,6 +73,7 @@ public struct MXRoomListDataSortOptions: Equatable { self.lastEventDate = lastEventDate self.favoriteTag = favoriteTag self.suggested = suggested + self.alphabetical = alphabetical self.missedNotificationsFirst = missedNotificationsFirst self.unreadMessagesFirst = unreadMessagesFirst } diff --git a/MatrixSDK/Data/RoomList/MXStore/MXStoreRoomListDataManager.swift b/MatrixSDK/Data/RoomList/MXStore/MXStoreRoomListDataManager.swift index 7bb698b587..eab91f3f1e 100644 --- a/MatrixSDK/Data/RoomList/MXStore/MXStoreRoomListDataManager.swift +++ b/MatrixSDK/Data/RoomList/MXStore/MXStoreRoomListDataManager.swift @@ -34,6 +34,9 @@ public class MXStoreRoomListDataManager: NSObject, MXRoomListDataManager { session: session, spaceService: spaceService) } + if options.filterOptions.onlyBreadcrumbs { + return MXBreadcrumbsRoomListDataFetcher(fetchOptions: options, session: session) + } guard let store = session?.store else { fatalError("[MXStoreRoomListDataManager] Session has no store") } diff --git a/MatrixSDK/Data/Store/MXMemoryStore/MXMemoryStore.m b/MatrixSDK/Data/Store/MXMemoryStore/MXMemoryStore.m index b0c548ea4b..1ad1146480 100644 --- a/MatrixSDK/Data/Store/MXMemoryStore/MXMemoryStore.m +++ b/MatrixSDK/Data/Store/MXMemoryStore/MXMemoryStore.m @@ -195,6 +195,11 @@ - (NSAttributedString *)partialAttributedTextMessageOfRoom:(NSString *)roomId return roomStore.partialAttributedTextMessage; } +- (void)stateOfRoom:(NSString *)roomId success:(void (^)(NSArray * _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure +{ + success(@[]); +} + - (void)loadReceiptsForRoom:(NSString *)roomId completion:(void (^)(void))completion { [self getOrCreateRoomReceiptsStore:roomId]; diff --git a/MatrixSDK/MXRestClient.h b/MatrixSDK/MXRestClient.h index ac23d09747..2f37ed01dd 100644 --- a/MatrixSDK/MXRestClient.h +++ b/MatrixSDK/MXRestClient.h @@ -74,6 +74,7 @@ FOUNDATION_EXPORT NSString *const kMXAccountDataTypeIgnoredUserList; FOUNDATION_EXPORT NSString *const kMXAccountDataTypeUserWidgets; FOUNDATION_EXPORT NSString *const kMXAccountDataTypeIdentityServer; FOUNDATION_EXPORT NSString *const kMXAccountDataTypeAcceptedTerms; +FOUNDATION_EXPORT NSString *const kMXAccountDataTypeBreadcrumbs; FOUNDATION_EXPORT NSString *const kMXAccountDataTypeAcceptedTermsKey; /** @@ -81,6 +82,7 @@ FOUNDATION_EXPORT NSString *const kMXAccountDataTypeAcceptedTermsKey; */ FOUNDATION_EXPORT NSString *const kMXAccountDataKeyIgnoredUser; FOUNDATION_EXPORT NSString *const kMXAccountDataKeyIdentityServer; +FOUNDATION_EXPORT NSString *const kMXAccountDataTypeRecentRoomsKey; /** diff --git a/MatrixSDK/MXRestClient.m b/MatrixSDK/MXRestClient.m index 5d0c8fa39f..a7cbf0cc09 100644 --- a/MatrixSDK/MXRestClient.m +++ b/MatrixSDK/MXRestClient.m @@ -51,6 +51,7 @@ NSString *const kMXAccountDataTypeUserWidgets = @"m.widgets"; NSString *const kMXAccountDataTypeIdentityServer = @"m.identity_server"; NSString *const kMXAccountDataTypeAcceptedTerms = @"m.accepted_terms"; +NSString *const kMXAccountDataTypeBreadcrumbs = @"im.vector.setting.breadcrumbs"; /** Account data keys @@ -58,6 +59,7 @@ NSString *const kMXAccountDataKeyIgnoredUser = @"ignored_users"; NSString *const kMXAccountDataKeyIdentityServer = @"base_url"; NSString *const kMXAccountDataTypeAcceptedTermsKey = @"accepted"; +NSString *const kMXAccountDataTypeRecentRoomsKey = @"recent_rooms"; /** Types of third party media. @@ -2470,6 +2472,11 @@ - (MXHTTPOperation*)joinRoom:(NSString*)roomIdOrAlias @"third_party_signed":thirdPartySigned }; } + else + { + // A body is required even if empty + parameters = @{}; + } // Characters in a room alias need to be escaped in the URL NSString *path = [NSString stringWithFormat:@"%@/join/%@", diff --git a/MatrixSDK/MXSession.h b/MatrixSDK/MXSession.h index 22b145c313..7aa8d486d8 100644 --- a/MatrixSDK/MXSession.h +++ b/MatrixSDK/MXSession.h @@ -224,6 +224,8 @@ FOUNDATION_EXPORT NSString *const kMXSessionAccountDataDidChangeNotification; */ FOUNDATION_EXPORT NSString *const kMXSessionAccountDataDidChangeIdentityServerNotification; +FOUNDATION_EXPORT NSString *const kMXSessionAccountDataDidChangeBreadcrumbsNotification; + /** Posted when MXSession data have been corrupted. The listener must reload the session data with a full server sync. @@ -1482,6 +1484,9 @@ typedef void (^MXOnBackgroundSyncFail)(NSError *error); success:(void (^)(MXSession *session, NSString *baseURL, NSString *accessToken))success failure:(void (^)(NSError *error))failure; +- (void)updateBreadcrumbsWithRoomWithId:(NSString *)roomId + success:(void (^)(void))success + failure:(void (^)(NSError *error))failure; #pragma mark - Homeserver information diff --git a/MatrixSDK/MXSession.m b/MatrixSDK/MXSession.m index 7534524075..15b602e47e 100644 --- a/MatrixSDK/MXSession.m +++ b/MatrixSDK/MXSession.m @@ -61,6 +61,7 @@ NSString *const kMXSessionVirtualRoomsDidChangeNotification = @"kMXSessionVirtualRoomsDidChangeNotification"; NSString *const kMXSessionAccountDataDidChangeNotification = @"kMXSessionAccountDataDidChangeNotification"; NSString *const kMXSessionAccountDataDidChangeIdentityServerNotification = @"kMXSessionAccountDataDidChangeIdentityServerNotification"; +NSString *const kMXSessionAccountDataDidChangeBreadcrumbsNotification = @"kMXSessionAccountDataDidChangeBreadcrumbsNotification"; NSString *const kMXSessionDidCorruptDataNotification = @"kMXSessionDidCorruptDataNotification"; NSString *const kMXSessionCryptoDidCorruptDataNotification = @"kMXSessionCryptoDidCorruptDataNotification"; NSString *const kMXSessionNewGroupInviteNotification = @"kMXSessionNewGroupInviteNotification"; @@ -1858,6 +1859,13 @@ - (void)handleAccountData:(NSDictionary*)accountDataUpdate [self refreshIdentityServerServiceTerms]; } } + + if ([event[@"type"] isEqualToString:kMXAccountDataTypeBreadcrumbs]) + { + [[NSNotificationCenter defaultCenter] postNotificationName:kMXSessionAccountDataDidChangeBreadcrumbsNotification + object:self + userInfo:nil]; + } } [self validateAccountData]; @@ -4458,6 +4466,35 @@ - (void)prepareIdentityServiceForTermsWithDefault:(NSString *)defaultIdentitySer }]; } +- (void)updateBreadcrumbsWithRoomWithId:(NSString *)roomId + success:(void (^)(void))success + failure:(void (^)(NSError *error))failure +{ + NSDictionary *breadcrumbs = [self.accountData accountDataForEventType:kMXAccountDataTypeBreadcrumbs]; + + NSMutableArray *recentRoomIds = breadcrumbs[kMXAccountDataTypeRecentRoomsKey] ? [NSMutableArray arrayWithArray:breadcrumbs[kMXAccountDataTypeRecentRoomsKey]] : [NSMutableArray array]; + + NSInteger index = [recentRoomIds indexOfObject:roomId]; + if (index != NSNotFound) + { + [recentRoomIds removeObjectAtIndex:index]; + } + [recentRoomIds insertObject:roomId atIndex:0]; + + [self setAccountData:@{kMXAccountDataTypeRecentRoomsKey : recentRoomIds} + forType:kMXAccountDataTypeBreadcrumbs + success:^{ + if (success) + { + success(); + } + } failure:^(NSError *error) { + if (failure) + { + failure(error); + } + }]; +} #pragma mark - Homeserver information - (MXWellKnown *)homeserverWellknown diff --git a/MatrixSDK/MatrixSDKVersion.m b/MatrixSDK/MatrixSDKVersion.m index 84a8fdafa9..985e8334de 100644 --- a/MatrixSDK/MatrixSDKVersion.m +++ b/MatrixSDK/MatrixSDKVersion.m @@ -16,4 +16,4 @@ #import -NSString *const MatrixSDKVersion = @"0.23.13"; +NSString *const MatrixSDKVersion = @"0.23.14"; diff --git a/MatrixSDK/Space/MXSpace.swift b/MatrixSDK/Space/MXSpace.swift index 136fe043f7..6c1533c436 100644 --- a/MatrixSDK/Space/MXSpace.swift +++ b/MatrixSDK/Space/MXSpace.swift @@ -333,13 +333,22 @@ public class MXSpace: NSObject { return } let userPowerLevel = powerLevels.powerLevelOfUser(withUserID: userId) - let minimumPowerLevel = powerLevels.events["m.space.child"] as? Int ?? powerLevels.stateDefault + let minimumPowerLevel = self.minimumPowerLevelForAddingRoom(with: powerLevels) let canAddRoom = userPowerLevel >= minimumPowerLevel completion(canAddRoom) } } + /// Returns the mimnimum power level required to add a room to this space + /// - Parameters: + /// - powerLevels: power levels of the room related to the space + /// + /// - Returns: the mimnimum power level required to add a room to this space + public func minimumPowerLevelForAddingRoom(with powerLevels: MXRoomPowerLevels) -> Int { + return powerLevels.events["m.space.child"] as? Int ?? powerLevels.stateDefault + } + // MARK: - Private private func updateChildRooms(from space: MXSpace, with directRoomsPerMember: [String : [String]]) { diff --git a/MatrixSDK/Space/MXSpaceNotificationCounter.swift b/MatrixSDK/Space/MXSpaceNotificationCounter.swift index 34bb5d49f5..fa5cdf1ead 100644 --- a/MatrixSDK/Space/MXSpaceNotificationCounter.swift +++ b/MatrixSDK/Space/MXSpaceNotificationCounter.swift @@ -87,7 +87,7 @@ public class MXSpaceNotificationCounter: NSObject { room.roomId } - let spaceIds: [String] = self.session.spaceService.rootSpaceSummaries.compactMap { summary in + let spaceIds: [String] = self.session.spaceService.spaceSummaries.compactMap { summary in summary.roomId } diff --git a/MatrixSDK/Space/MXSpaceService.swift b/MatrixSDK/Space/MXSpaceService.swift index c78e75f3c9..58d9b21535 100644 --- a/MatrixSDK/Space/MXSpaceService.swift +++ b/MatrixSDK/Space/MXSpaceService.swift @@ -90,6 +90,13 @@ public class MXSpaceService: NSObject { /// The instance of `MXSpaceNotificationCounter` that computes the number of unread messages for each space public let notificationCounter: MXSpaceNotificationCounter + /// List of `MXSpace` instances of the high level spaces. + public var rootSpaces: [MXSpace] { + return self.graph.rootSpaceIds.compactMap { spaceId in + self.getSpace(withId: spaceId) + } + } + /// List of `MXRoomSummary` of the high level spaces. public var rootSpaceSummaries: [MXRoomSummary] { return self.graph.rootSpaceIds.compactMap { spaceId in diff --git a/MatrixSDKTests/DirectRoomTests.m b/MatrixSDKTests/DirectRoomTests.m index 7be0c733fe..b435fe7c1e 100644 --- a/MatrixSDKTests/DirectRoomTests.m +++ b/MatrixSDKTests/DirectRoomTests.m @@ -42,9 +42,9 @@ - (void)setUp - (void)tearDown { + matrixSDKTestsData = nil; [super tearDown]; - matrixSDKTestsData = nil; } // Create the following scenario with 3 rooms diff --git a/MatrixSDKTests/MXAccountDataTests.m b/MatrixSDKTests/MXAccountDataTests.m index 51467f6ff4..0866d80fc3 100644 --- a/MatrixSDKTests/MXAccountDataTests.m +++ b/MatrixSDKTests/MXAccountDataTests.m @@ -42,9 +42,9 @@ - (void)setUp - (void)tearDown { - [super tearDown]; - matrixSDKTestsData = nil; + + [super tearDown]; } - (void)testIgnoreUser diff --git a/MatrixSDKTests/MXAggregatedEditsTests.m b/MatrixSDKTests/MXAggregatedEditsTests.m index 819d9a5225..277d0d3a95 100644 --- a/MatrixSDKTests/MXAggregatedEditsTests.m +++ b/MatrixSDKTests/MXAggregatedEditsTests.m @@ -57,6 +57,8 @@ - (void)tearDown { matrixSDKTestsData = nil; matrixSDKTestsE2EData = nil; + + [super tearDown]; } // Create a room with an event with an edit it on it diff --git a/MatrixSDKTests/MXAggregatedReactionTests.m b/MatrixSDKTests/MXAggregatedReactionTests.m index 5b281ef9b9..884c551538 100644 --- a/MatrixSDKTests/MXAggregatedReactionTests.m +++ b/MatrixSDKTests/MXAggregatedReactionTests.m @@ -48,6 +48,8 @@ - (void)setUp - (void)tearDown { matrixSDKTestsData = nil; + + [super tearDown]; } // Create a room with an event with a reaction on it diff --git a/MatrixSDKTests/MXAggregatedReferenceTests.m b/MatrixSDKTests/MXAggregatedReferenceTests.m index 8266851e12..e3db7cde05 100644 --- a/MatrixSDKTests/MXAggregatedReferenceTests.m +++ b/MatrixSDKTests/MXAggregatedReferenceTests.m @@ -53,6 +53,8 @@ - (void)tearDown { matrixSDKTestsData = nil; matrixSDKTestsE2EData = nil; + + [super tearDown]; } diff --git a/MatrixSDKTests/MXAsyncTaskQueueUnitTests.swift b/MatrixSDKTests/MXAsyncTaskQueueUnitTests.swift index 7a9a9a110b..328db35956 100644 --- a/MatrixSDKTests/MXAsyncTaskQueueUnitTests.swift +++ b/MatrixSDKTests/MXAsyncTaskQueueUnitTests.swift @@ -18,14 +18,6 @@ import XCTest class MXAsyncTaskQueueUnitTests: XCTestCase { - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - /// Check that tasks and async tasks are run func test() throws { let expectation = self.expectation(description: "test") diff --git a/MatrixSDKTests/MXAuthenticationSessionUnitTests.swift b/MatrixSDKTests/MXAuthenticationSessionUnitTests.swift index 78e8696e6f..8b18207631 100644 --- a/MatrixSDKTests/MXAuthenticationSessionUnitTests.swift +++ b/MatrixSDKTests/MXAuthenticationSessionUnitTests.swift @@ -20,14 +20,6 @@ import MatrixSDK class MXAuthenticationSessionUnitTests: XCTestCase { - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - func testParsing() throws { let json: [String: Any] = [ diff --git a/MatrixSDKTests/MXBackgroundSyncServiceTests.swift b/MatrixSDKTests/MXBackgroundSyncServiceTests.swift index 53f2485252..e246e62c76 100644 --- a/MatrixSDKTests/MXBackgroundSyncServiceTests.swift +++ b/MatrixSDKTests/MXBackgroundSyncServiceTests.swift @@ -29,6 +29,7 @@ class MXBackgroundSyncServiceTests: XCTestCase { } override func setUp() { + super.setUp() testData = MatrixSDKTestsData() e2eTestData = MatrixSDKTestsE2EData(matrixSDKTestsData: testData) } @@ -37,6 +38,7 @@ class MXBackgroundSyncServiceTests: XCTestCase { testData = nil e2eTestData = nil bgSyncService = nil + super.tearDown() } diff --git a/MatrixSDKTests/MXBeaconAggregationsTests.swift b/MatrixSDKTests/MXBeaconAggregationsTests.swift index 7988fe8348..748b4e07e2 100644 --- a/MatrixSDKTests/MXBeaconAggregationsTests.swift +++ b/MatrixSDKTests/MXBeaconAggregationsTests.swift @@ -28,12 +28,14 @@ class MXBeaconAggregationsTests: XCTestCase { // MARK: - Setup override func setUp() { + super.setUp() testData = MatrixSDKTestsData() MXSDKOptions.sharedInstance().enableThreads = true } override func tearDown() { testData = nil + super.tearDown() } // MARK: - Tests diff --git a/MatrixSDKTests/MXCoreDataRoomListDataManagerUnitTests.swift b/MatrixSDKTests/MXCoreDataRoomListDataManagerUnitTests.swift index e9b7f5ef7e..fbe1ddc51e 100644 --- a/MatrixSDKTests/MXCoreDataRoomListDataManagerUnitTests.swift +++ b/MatrixSDKTests/MXCoreDataRoomListDataManagerUnitTests.swift @@ -34,6 +34,7 @@ class MXCoreDataRoomListDataManagerUnitTests: XCTestCase { } override class func setUp() { + super.setUp() MXSDKOptions.sharedInstance().roomListDataManagerClass = MXCoreDataRoomListDataManager.self MXRealmCryptoStore.deleteAllStores() } @@ -42,6 +43,7 @@ class MXCoreDataRoomListDataManagerUnitTests: XCTestCase { fetcher?.stop() fetcher = nil delegate = nil + super.tearDown() } private var basicFetchOptions: MXRoomListDataFetchOptions { diff --git a/MatrixSDKTests/MXCrossSigningTests.m b/MatrixSDKTests/MXCrossSigningTests.m index 516bc125fe..030e6fc1cd 100644 --- a/MatrixSDKTests/MXCrossSigningTests.m +++ b/MatrixSDKTests/MXCrossSigningTests.m @@ -70,6 +70,8 @@ - (void)tearDown { [[NSNotificationCenter defaultCenter] removeObserver:observer]; } + + [super tearDown]; } diff --git a/MatrixSDKTests/MXCryptoRecoveryServiceTests.m b/MatrixSDKTests/MXCryptoRecoveryServiceTests.m index 812ad11021..86a12cb155 100644 --- a/MatrixSDKTests/MXCryptoRecoveryServiceTests.m +++ b/MatrixSDKTests/MXCryptoRecoveryServiceTests.m @@ -45,6 +45,8 @@ - (void)tearDown { matrixSDKTestsData = nil; matrixSDKTestsE2EData = nil; + + [super tearDown]; } diff --git a/MatrixSDKTests/MXCryptoSecretShareTests.m b/MatrixSDKTests/MXCryptoSecretShareTests.m index d3dcee2a26..ebc76297be 100644 --- a/MatrixSDKTests/MXCryptoSecretShareTests.m +++ b/MatrixSDKTests/MXCryptoSecretShareTests.m @@ -48,6 +48,8 @@ - (void)tearDown { matrixSDKTestsData = nil; matrixSDKTestsE2EData = nil; + + [super tearDown]; } /** diff --git a/MatrixSDKTests/MXCryptoSecretStorageTests.m b/MatrixSDKTests/MXCryptoSecretStorageTests.m index 3d1901d8ea..1c63e28fd5 100644 --- a/MatrixSDKTests/MXCryptoSecretStorageTests.m +++ b/MatrixSDKTests/MXCryptoSecretStorageTests.m @@ -66,6 +66,8 @@ - (void)tearDown { matrixSDKTestsData = nil; matrixSDKTestsE2EData = nil; + + [super tearDown]; } diff --git a/MatrixSDKTests/MXEventAnnotationUnitTests.swift b/MatrixSDKTests/MXEventAnnotationUnitTests.swift index 811e14fadc..fea7d607f9 100644 --- a/MatrixSDKTests/MXEventAnnotationUnitTests.swift +++ b/MatrixSDKTests/MXEventAnnotationUnitTests.swift @@ -40,12 +40,6 @@ class MXEventAnnotationUnitTests: XCTestCase { ] ] - override func setUp() { - } - - override func tearDown() { - } - func testModelFromJSON() { let event = MXEvent(fromJSON: eventJSON) diff --git a/MatrixSDKTests/MXEventReferenceUnitTests.swift b/MatrixSDKTests/MXEventReferenceUnitTests.swift index c3e047dc21..5a4ed29ab4 100644 --- a/MatrixSDKTests/MXEventReferenceUnitTests.swift +++ b/MatrixSDKTests/MXEventReferenceUnitTests.swift @@ -39,12 +39,6 @@ class MXEventReferenceUnitTests: XCTestCase { ] ] - override func setUp() { - } - - override func tearDown() { - } - func testModelFromJSON() { let event = MXEvent(fromJSON: eventJSON) diff --git a/MatrixSDKTests/MXEventScanStoreUnitTests.m b/MatrixSDKTests/MXEventScanStoreUnitTests.m index 8af69919dd..51477be914 100644 --- a/MatrixSDKTests/MXEventScanStoreUnitTests.m +++ b/MatrixSDKTests/MXEventScanStoreUnitTests.m @@ -34,7 +34,7 @@ @implementation MXEventScanStoreUnitTests - (void)setUp { - // Put setup code here. This method is called before the invocation of each test method in the class. + [super setUp]; id realmProvider = [[MXScanRealmInMemoryProvider alloc] initWithAntivirusServerDomain:kDefaultAntivirusServerDomain]; self.eventScanStore = [[MXRealmEventScanStore alloc] initWithRealmProvider:realmProvider]; @@ -44,7 +44,7 @@ - (void)setUp - (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; } - (void)testCreateEventScan diff --git a/MatrixSDKTests/MXHTTPAdditionalHeadersUnitTests.m b/MatrixSDKTests/MXHTTPAdditionalHeadersUnitTests.m index 68594eb816..8d7b2e4b8b 100644 --- a/MatrixSDKTests/MXHTTPAdditionalHeadersUnitTests.m +++ b/MatrixSDKTests/MXHTTPAdditionalHeadersUnitTests.m @@ -63,7 +63,7 @@ - (void)stubRequestsContaining:(NSString*)path withJSONResponse:(nullable NSDict - (void)setUp { - // Put setup code here. This method is called before the invocation of each test method in the class. + [super setUp]; } - (void)tearDown diff --git a/MatrixSDKTests/MXHTTPClientTests.m b/MatrixSDKTests/MXHTTPClientTests.m index dd9609a89b..fb7845464b 100644 --- a/MatrixSDKTests/MXHTTPClientTests.m +++ b/MatrixSDKTests/MXHTTPClientTests.m @@ -29,18 +29,6 @@ @interface MXHTTPClientTests : XCTestCase @implementation MXHTTPClientTests -- (void)setUp -{ - [super setUp]; - // Put setup code here. This method is called before the invocation of each test method in the class. -} - -- (void)tearDown -{ - // Put teardown code here. This method is called after the invocation of each test method in the class. - [super tearDown]; -} - - (void)testMainThread { diff --git a/MatrixSDKTests/MXHomeserverCapabilitiesTests.swift b/MatrixSDKTests/MXHomeserverCapabilitiesTests.swift index 7fa6690edb..f04ac310a7 100644 --- a/MatrixSDKTests/MXHomeserverCapabilitiesTests.swift +++ b/MatrixSDKTests/MXHomeserverCapabilitiesTests.swift @@ -184,12 +184,14 @@ class MXHomeserverCapabilitiesTests: XCTestCase { override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. + try super.setUpWithError() testData = MatrixSDKTestsData() } override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. testData = nil + try super.tearDownWithError() } // MARK: - Tests diff --git a/MatrixSDKTests/MXKeyProviderUnitTests.m b/MatrixSDKTests/MXKeyProviderUnitTests.m index f3ecb9fe2f..880f7b5cb8 100644 --- a/MatrixSDKTests/MXKeyProviderUnitTests.m +++ b/MatrixSDKTests/MXKeyProviderUnitTests.m @@ -29,6 +29,7 @@ @interface MXKeyProviderUnitTests : XCTestCase @implementation MXKeyProviderUnitTests - (void)setUp { + [super setUp]; self.isEncryptionAvailable = YES; NSData *iv = [@"baB6pgMP9erqSaKF" dataUsingEncoding:NSUTF8StringEncoding]; NSData *aesKey = [@"6fXK17pQFUrFqOnxt3wrqz8RHkQUT9vQ" dataUsingEncoding:NSUTF8StringEncoding]; @@ -37,7 +38,7 @@ - (void)setUp { } - (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; } - (void)testNoDelegateSet { diff --git a/MatrixSDKTests/MXLazyLoadingTests.m b/MatrixSDKTests/MXLazyLoadingTests.m index e214e9f7e2..4d1aadaec8 100644 --- a/MatrixSDKTests/MXLazyLoadingTests.m +++ b/MatrixSDKTests/MXLazyLoadingTests.m @@ -49,10 +49,10 @@ - (void)setUp - (void)tearDown { - [super tearDown]; [MXHTTPClient removeAllDelays]; - matrixSDKTestsData = nil; + + [super tearDown]; } /** diff --git a/MatrixSDKTests/MXLocationServiceTests.swift b/MatrixSDKTests/MXLocationServiceTests.swift index 57a73b8191..6e829768db 100644 --- a/MatrixSDKTests/MXLocationServiceTests.swift +++ b/MatrixSDKTests/MXLocationServiceTests.swift @@ -28,12 +28,14 @@ class MXLocationServiceTests: XCTestCase { // MARK: - Setup override func setUp() { + super.setUp() testData = MatrixSDKTestsData() MXSDKOptions.sharedInstance().enableThreads = true } override func tearDown() { testData = nil + super.tearDown() } // MARK: - Tests diff --git a/MatrixSDKTests/MXMediaScanStoreUnitTests.m b/MatrixSDKTests/MXMediaScanStoreUnitTests.m index 67e9454456..3b9efcea07 100644 --- a/MatrixSDKTests/MXMediaScanStoreUnitTests.m +++ b/MatrixSDKTests/MXMediaScanStoreUnitTests.m @@ -33,7 +33,7 @@ @implementation MXMediaScanStoreUnitTests - (void)setUp { - // Put setup code here. This method is called before the invocation of each test method in the class. + [super setUp]; id realmProvider = [[MXScanRealmInMemoryProvider alloc] initWithAntivirusServerDomain:kDefaultAntivirusServerDomain]; self.mediaScanStore = [[MXRealmMediaScanStore alloc] initWithRealmProvider:realmProvider]; @@ -43,7 +43,7 @@ - (void)setUp - (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; } - (void)testCreateMediaScan diff --git a/MatrixSDKTests/MXMegolmExportEncryptionUnitTests.m b/MatrixSDKTests/MXMegolmExportEncryptionUnitTests.m index b3de950dbc..c704458e5b 100644 --- a/MatrixSDKTests/MXMegolmExportEncryptionUnitTests.m +++ b/MatrixSDKTests/MXMegolmExportEncryptionUnitTests.m @@ -27,16 +27,6 @@ @interface MXMegolmExportEncryptionUnitTests : XCTestCase @implementation MXMegolmExportEncryptionUnitTests -- (void)setUp -{ - [super setUp]; -} - -- (void)tearDown -{ - [super tearDown]; -} - - (void)testDecrypt { NSArray *TEST_VECTORS = @[ diff --git a/MatrixSDKTests/MXPollAggregatorTests.swift b/MatrixSDKTests/MXPollAggregatorTests.swift index bdfeb716f4..da236d8b26 100644 --- a/MatrixSDKTests/MXPollAggregatorTests.swift +++ b/MatrixSDKTests/MXPollAggregatorTests.swift @@ -24,6 +24,7 @@ class MXPollAggregatorTest: XCTestCase { private var pollAggregator: PollAggregator! override func setUp() { + super.setUp() matrixSDKTestsData = MatrixSDKTestsData() matrixSDKTestsE2EData = MatrixSDKTestsE2EData(matrixSDKTestsData: matrixSDKTestsData) } @@ -31,6 +32,7 @@ class MXPollAggregatorTest: XCTestCase { override func tearDown() { matrixSDKTestsData = nil matrixSDKTestsE2EData = nil + super.tearDown() } func testAggregations() { diff --git a/MatrixSDKTests/MXPollRelationTests.m b/MatrixSDKTests/MXPollRelationTests.m index a8f9b54e26..1a213bf105 100644 --- a/MatrixSDKTests/MXPollRelationTests.m +++ b/MatrixSDKTests/MXPollRelationTests.m @@ -47,6 +47,8 @@ - (void)tearDown { self.matrixSDKTestsData = nil; self.matrixSDKTestsE2EData = nil; + + [super tearDown]; } - (void)testBobClosesPollWithOneAnswer diff --git a/MatrixSDKTests/MXPushRuleUnitTests.m b/MatrixSDKTests/MXPushRuleUnitTests.m index a816cb2a12..c840f6f76d 100644 --- a/MatrixSDKTests/MXPushRuleUnitTests.m +++ b/MatrixSDKTests/MXPushRuleUnitTests.m @@ -47,15 +47,6 @@ @interface MXPushRuleUnitTests : XCTestCase #pragma mark - MXPushRuleTests helper methods @implementation MXPushRuleUnitTests -- (void)setUp -{ - [super setUp]; -} - -- (void)tearDown -{ - [super tearDown]; -} - (MXPushRule *)contentRuleWithPattern:(NSString*)pattern { diff --git a/MatrixSDKTests/MXQRCodeDataUnitTests.m b/MatrixSDKTests/MXQRCodeDataUnitTests.m index a18a916452..04ab9f38cc 100644 --- a/MatrixSDKTests/MXQRCodeDataUnitTests.m +++ b/MatrixSDKTests/MXQRCodeDataUnitTests.m @@ -26,16 +26,6 @@ @interface MXQRCodeDataUnitTests : XCTestCase @implementation MXQRCodeDataUnitTests -- (void)setUp -{ - // Put setup code here. This method is called before the invocation of each test method in the class. -} - -- (void)tearDown -{ - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - - (void)testDecode { MXQRCodeVerificationMode expectedVerificationMode = MXQRCodeVerificationModeVerifyingAnotherUser; diff --git a/MatrixSDKTests/MXReplyEventParserUnitTests.m b/MatrixSDKTests/MXReplyEventParserUnitTests.m index 3992d7e330..6c39eecb48 100644 --- a/MatrixSDKTests/MXReplyEventParserUnitTests.m +++ b/MatrixSDKTests/MXReplyEventParserUnitTests.m @@ -25,14 +25,6 @@ @interface MXReplyEventParserUnitTests : XCTestCase @implementation MXReplyEventParserUnitTests -- (void)setUp { - // Put setup code here. This method is called before the invocation of each test method in the class. -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - - (MXEvent*)fakeReplyEventWithBody:(NSString*)body andFormattedBody:(NSString*)formattedBody { NSDictionary *replyEventDict = @{ diff --git a/MatrixSDKTests/MXRestClientNoAuthAPITests.m b/MatrixSDKTests/MXRestClientNoAuthAPITests.m index a3ea75b074..0fb52ced77 100644 --- a/MatrixSDKTests/MXRestClientNoAuthAPITests.m +++ b/MatrixSDKTests/MXRestClientNoAuthAPITests.m @@ -49,11 +49,11 @@ - (void)setUp - (void)tearDown { - [super tearDown]; - [MXHTTPClient removeAllDelays]; mxRestClient = nil; matrixSDKTestsData = nil; + + [super tearDown]; } // Make sure MXTESTS_USER exists on the HS diff --git a/MatrixSDKTests/MXRestClientTests.m b/MatrixSDKTests/MXRestClientTests.m index d9961314bf..2406d6445d 100644 --- a/MatrixSDKTests/MXRestClientTests.m +++ b/MatrixSDKTests/MXRestClientTests.m @@ -48,9 +48,9 @@ - (void)setUp - (void)tearDown { - [super tearDown]; - _matrixSDKTestsData = nil; + + [super tearDown]; } - (void)testInit diff --git a/MatrixSDKTests/MXRoomAliasAvailabilityCheckerResultTests.swift b/MatrixSDKTests/MXRoomAliasAvailabilityCheckerResultTests.swift index b47fd3baac..8bb15511a4 100644 --- a/MatrixSDKTests/MXRoomAliasAvailabilityCheckerResultTests.swift +++ b/MatrixSDKTests/MXRoomAliasAvailabilityCheckerResultTests.swift @@ -27,12 +27,14 @@ class MXRoomAliasAvailabilityCheckerResultTests: XCTestCase { override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. + try super.setUpWithError() testData = MatrixSDKTestsData() } override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. testData = nil + try super.tearDownWithError() } // MARK: - Tests diff --git a/MatrixSDKTests/MXSpaceServiceTest.swift b/MatrixSDKTests/MXSpaceServiceTest.swift index a8be833744..39dc6e8028 100644 --- a/MatrixSDKTests/MXSpaceServiceTest.swift +++ b/MatrixSDKTests/MXSpaceServiceTest.swift @@ -32,12 +32,16 @@ class MXSpaceServiceTest: XCTestCase { override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. - testData = MatrixSDKTestsData() + try super.setUpWithError() + + testData = MatrixSDKTestsData() } override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. testData = nil + + try super.tearDownWithError() } // MARK: - Private diff --git a/MatrixSDKTests/MXThreadingServiceTests.swift b/MatrixSDKTests/MXThreadingServiceTests.swift index 9b306c630a..122a013b72 100644 --- a/MatrixSDKTests/MXThreadingServiceTests.swift +++ b/MatrixSDKTests/MXThreadingServiceTests.swift @@ -21,12 +21,14 @@ class MXThreadingServiceTests: XCTestCase { private var testData: MatrixSDKTestsData! override func setUp() { + super.setUp() testData = MatrixSDKTestsData() MXSDKOptions.sharedInstance().enableThreads = true } override func tearDown() { testData = nil + super.tearDown() } /// Test: Expect the threading service is initialized after creating a session diff --git a/MatrixSDKTests/MXToolsUnitTests.m b/MatrixSDKTests/MXToolsUnitTests.m index 69a3c1699f..65b58da8c9 100644 --- a/MatrixSDKTests/MXToolsUnitTests.m +++ b/MatrixSDKTests/MXToolsUnitTests.m @@ -25,16 +25,6 @@ @interface MXToolsUnitTests : XCTestCase @implementation MXToolsUnitTests -- (void)setUp -{ - [super setUp]; -} - -- (void)tearDown -{ - [super tearDown]; -} - - (void)testGenerateSecret { NSString *secret = [MXTools generateSecret]; diff --git a/MatrixSDKTests/TestPlans/AllWorkingTests.xctestplan b/MatrixSDKTests/TestPlans/AllWorkingTests.xctestplan new file mode 100644 index 0000000000..24fd2e67a5 --- /dev/null +++ b/MatrixSDKTests/TestPlans/AllWorkingTests.xctestplan @@ -0,0 +1,129 @@ +{ + "configurations" : [ + { + "id" : "FBC4E845-6EC4-4E21-9D46-61B9D0202049", + "name" : "Configuration 1", + "options" : { + + } + } + ], + "defaultOptions" : { + + }, + "testTargets" : [ + { + "skippedTests" : [ + "DirectRoomTests\/testDirectRoomsAfterInitialSync", + "DirectRoomTests\/testDirectRoomsRaceConditions", + "DirectRoomTests\/testSummaryAfterInitialSyncAndStorage", + "MXAggregatedEditsTests\/testEditSendAndReceive", + "MXAggregatedEditsTests\/testEditSendAndReceiveInE2ERoom", + "MXAggregatedEditsTests\/testEditServerSide", + "MXAggregatedEditsTests\/testEditServerSideInE2ERoom", + "MXAggregatedEditsTests\/testEditsFromInitialSync", + "MXAggregatedEditsTests\/testFormatedEditsFromInitialSync", + "MXAggregatedEditsTests\/testFormattedEditSendAndReceive", + "MXAggregatedEditsUnitTests", + "MXAggregatedReferenceUnitTests", + "MXAsyncTaskQueueUnitTests", + "MXAuthenticationSessionUnitTests", + "MXAggregatedEditsTests\/testFormattedEditServerSide", + "MXAggregatedReactionTests\/testAggregationsFromInitialSync", + "MXAggregatedReactionTests\/testReactionsWhenPaginatingFromAGappyInitialSync", + "MXAggregatedReactionTests\/testReactionsWhenPaginatingFromAGappySync", + "MXAggregatedReactionTests\/testUnreactAfterInitialSync", + "MXAggregatedReferenceTests\/testReferenceFromInitialSync", + "MXAutoDiscoveryTests\/testAutoDiscoveryNotJSON", + "MXAutoDiscoveryTests\/testAutoDiscoverySuccessful", + "MXAutoDiscoveryTests\/testAutoDiscoverySuccessfulWithNoContentType", + "MXBackgroundTaskUnitTests", + "MXBeaconInfoUnitTests", + "MXCredentialsUnitTests", + "MXBackgroundSyncServiceTests\/testStoreWithGappyAndOutdatedSync()", + "MXCrossSigningTests", + "MXCrossSigningVerificationTests", + "MXCrossSigningVerificationTests\/testVerificationByDMFullFlow", + "MXCrossSigningVerificationTests\/testVerifyingAnotherUserQRCodeVerificationFullFlow", + "MXCryptoBackupTests", + "MXCryptoKeyVerificationTests", + "MXCryptoKeyVerificationTests\/testVerificationByDMFullFlow", + "MXCryptoKeyVerificationTests\/testVerificationByDMWithAUserWith2Devices", + "MXCryptoKeyVerificationTests\/testVerificationByDMWithAliceWith2Devices", + "MXCryptoRecoveryServiceTests", + "MXCryptoRequestsUnitTests", + "MXCryptoSecretShareTests\/testSecretRequestCancellation", + "MXCryptoShareTests", + "MXCryptoTests", + "MXErrorUnitTests", + "MXEventAnnotationUnitTests", + "MXEventReferenceUnitTests", + "MXEventScanStoreUnitTests", + "MXFilterTests\/testFilterAPI", + "MXFilterTests\/testFilterCache", + "MXFilterUnitTests", + "MXGeoURIComponentsUnitTests", + "MXHTTPClientTests\/testMainThread", + "MXJSONModelTests\/testModelFromJSON", + "MXJSONModelTests\/testModelsFromJSON", + "MXJSONModelUnitTests", + "MXKeyProviderUnitTests", + "MXLazyLoadingTests", + "MXLocationServiceTests", + "MXLoggerUnitTests", + "MXMediaScanStoreUnitTests", + "MXMegolmDecryptionUnitTests", + "MXMegolmEncryptionTests", + "MXMegolmExportEncryptionUnitTests", + "MXMegolmSessionDataUnitTests", + "MXMemoryRoomStoreUnitTests", + "MXMyUserTests\/testIdenticon", + "MXOlmDeviceUnitTests", + "MXPeekingRoomTests\/testPeekingOnNonWorldReadable", + "MXPollRelationTests\/testBobAndAliceAnswer", + "MXPollAggregatorTest\/testEditing()", + "MXPushRuleUnitTests", + "MXQRCodeDataUnitTests", + "MXReplyEventParserUnitTests", + "MXResponseUnitTests", + "MXRestClientExtensionsTests", + "MXRestClientNoAuthAPITests", + "MXRestClientTests\/testJoinRoomWithRoomAlias", + "MXRoomListDataManagerTests\/testNewRoomInvite()", + "MXRoomListDataManagerTests\/testRoomLeave()", + "MXRoomListDataManagerTests\/testRoomUpdateWhenReceivingEvent()", + "MXRoomStateTests\/testDeallocation", + "MXRoomStateTests\/testInviteByOtherInInitialSync", + "MXRoomStateTests\/testInviteByOtherInLive", + "MXRoomStateUnitTests", + "MXRoomSummaryTests", + "MXRoomSummaryTrustTests", + "MXRoomTests", + "MXSelfSignedHomeserverTests\/testE2ERoomAndMessages", + "MXSelfSignedHomeserverTests\/testNotTrustedCertificate", + "MXSelfSignedHomeserverTests\/testRegiter", + "MXSelfSignedHomeserverTests\/testRoomAndMessages", + "MXSelfSignedHomeserverTests\/testTrustedCertificate", + "MXSessionTests", + "MXSharedHistoryKeyManagerUnitTests", + "MXStoreFileStoreTests", + "MXStoreMemoryStoreTests", + "MXStoreNoStoreTests\/testMXNoStoreSeveralPaginateBacks", + "MXStoreRoomListDataManagerUnitTests", + "MXSyncResponseUnitTests", + "MXTaskQueueUnitTests", + "MXThreadEventTimelineUnitTests", + "MXThreadingServiceTests", + "MXThreadingServiceUnitTests", + "MXToolsUnitTests", + "MXUserTests" + ], + "target" : { + "containerPath" : "container:MatrixSDK.xcodeproj", + "identifier" : "B1E09A0D2397FA950057C069", + "name" : "MatrixSDKTests-macOS" + } + } + ], + "version" : 1 +}