Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/swift6 merge #1

Open
wants to merge 14 commits into
base: chore/migration-to-swift6
Choose a base branch
from
70 changes: 42 additions & 28 deletions Authorization/AuthorizationTests/AuthorizationMock.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,12 @@ open class CoreAnalyticsMock: CoreAnalytics, Mock {
// MARK: - CorePersistenceProtocol

open class CorePersistenceProtocolMock: CorePersistenceProtocol, Mock {
open func deleteDownloadDataTasks(ids: [String]) {
addInvocation(.m_deleteDownloadDataTasks__ids_ids(Parameter<[String]>.value(`ids`)))
let perform = methodPerformValue(.m_deleteDownloadDataTasks__ids_ids(Parameter<[String]>.value(`ids`))) as? ([String]) -> Void
perform?(`ids`)
}

public init(sequencing sequencingPolicy: SequencingPolicy = .lastWrittenResolvedFirst, stubbing stubbingPolicy: StubbingPolicy = .wrap, file: StaticString = #file, line: UInt = #line) {
SwiftyMockyTestObserver.setup()
self.sequencingPolicy = sequencingPolicy
Expand Down Expand Up @@ -2973,6 +2979,7 @@ open class CorePersistenceProtocolMock: CorePersistenceProtocol, Mock {
case m_downloadDataTask__for_blockId(Parameter<String>)
case m_getDownloadDataTasks
case m_getDownloadDataTasksForCourse__courseId(Parameter<String>)
case m_deleteDownloadDataTasks__ids_ids(Parameter<[String]>)

static func compareParameters(lhs: MethodType, rhs: MethodType, matcher: Matcher) -> Matcher.ComparisonResult {
switch (lhs, rhs) {
Expand Down Expand Up @@ -3045,6 +3052,10 @@ open class CorePersistenceProtocolMock: CorePersistenceProtocol, Mock {
var results: [Matcher.ParameterComparisonResult] = []
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsCourseid, rhs: rhsCourseid, with: matcher), lhsCourseid, rhsCourseid, "_ courseId"))
return Matcher.ComparisonResult(results)
case (.m_deleteDownloadDataTasks__ids_ids(let lhsIds), .m_deleteDownloadDataTasks__ids_ids(let rhsIds)):
var results: [Matcher.ParameterComparisonResult] = []
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsIds, rhs: rhsIds, with: matcher), lhsIds, rhsIds, "ids"))
return Matcher.ComparisonResult(results)
default: return .none
}
}
Expand All @@ -3068,6 +3079,7 @@ open class CorePersistenceProtocolMock: CorePersistenceProtocol, Mock {
case let .m_downloadDataTask__for_blockId(p0): return p0.intValue
case .m_getDownloadDataTasks: return 0
case let .m_getDownloadDataTasksForCourse__courseId(p0): return p0.intValue
case let .m_deleteDownloadDataTasks__ids_ids(p0): return p0.intValue
}
}
func assertionName() -> String {
Expand All @@ -3089,6 +3101,7 @@ open class CorePersistenceProtocolMock: CorePersistenceProtocol, Mock {
case .m_downloadDataTask__for_blockId: return ".downloadDataTask(for:)"
case .m_getDownloadDataTasks: return ".getDownloadDataTasks()"
case .m_getDownloadDataTasksForCourse__courseId: return ".getDownloadDataTasksForCourse(_:)"
case .m_deleteDownloadDataTasks__ids_ids: return ".deleteDownloadDataTasks(ids:)"
}
}
}
Expand Down Expand Up @@ -3516,15 +3529,9 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {
}
}

open func deleteFile(blocks: [CourseBlock]) {
addInvocation(.m_deleteFile__blocks_blocks(Parameter<[CourseBlock]>.value(`blocks`)))
let perform = methodPerformValue(.m_deleteFile__blocks_blocks(Parameter<[CourseBlock]>.value(`blocks`))) as? ([CourseBlock]) -> Void
perform?(`blocks`)
}

open func deleteAllFiles() {
addInvocation(.m_deleteAllFiles)
let perform = methodPerformValue(.m_deleteAllFiles) as? () -> Void
open func deleteAll() {
addInvocation(.m_deleteAll)
let perform = methodPerformValue(.m_deleteAll) as? () -> Void
perform?()
}

Expand Down Expand Up @@ -3588,6 +3595,12 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {
perform?()
}

open func delete(blocks: [CourseBlock], courseId: String) {
addInvocation(.m_delete__blocks_blockscourseId_courseId(Parameter<[CourseBlock]>.value(`blocks`), Parameter<String>.value(`courseId`)))
let perform = methodPerformValue(.m_delete__blocks_blockscourseId_courseId(Parameter<[CourseBlock]>.value(`blocks`), Parameter<String>.value(`courseId`))) as? ([CourseBlock], String) -> Void
perform?(`blocks`, `courseId`)
}


fileprivate enum MethodType {
case m_publisher
Expand All @@ -3599,13 +3612,13 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {
case m_cancelDownloading__task_task(Parameter<DownloadDataTask>)
case m_cancelDownloading__courseId_courseId(Parameter<String>)
case m_cancelAllDownloading
case m_deleteFile__blocks_blocks(Parameter<[CourseBlock]>)
case m_deleteAllFiles
case m_deleteAll
case m_fileUrl__for_blockId(Parameter<String>)
case m_updateUnzippedFileSize__for_sequentials(Parameter<[CourseSequential]>)
case m_resumeDownloading
case m_isLargeVideosSize__blocks_blocks(Parameter<[CourseBlock]>)
case m_removeAppSupportDirectoryUnusedContent
case m_delete__blocks_blockscourseId_courseId(Parameter<[CourseBlock]>, Parameter<String>)
case p_currentDownloadTask_get

static func compareParameters(lhs: MethodType, rhs: MethodType, matcher: Matcher) -> Matcher.ComparisonResult {
Expand Down Expand Up @@ -3644,12 +3657,7 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {

case (.m_cancelAllDownloading, .m_cancelAllDownloading): return .match

case (.m_deleteFile__blocks_blocks(let lhsBlocks), .m_deleteFile__blocks_blocks(let rhsBlocks)):
var results: [Matcher.ParameterComparisonResult] = []
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsBlocks, rhs: rhsBlocks, with: matcher), lhsBlocks, rhsBlocks, "blocks"))
return Matcher.ComparisonResult(results)

case (.m_deleteAllFiles, .m_deleteAllFiles): return .match
case (.m_deleteAll, .m_deleteAll): return .match

case (.m_fileUrl__for_blockId(let lhsBlockid), .m_fileUrl__for_blockId(let rhsBlockid)):
var results: [Matcher.ParameterComparisonResult] = []
Expand All @@ -3669,6 +3677,12 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {
return Matcher.ComparisonResult(results)

case (.m_removeAppSupportDirectoryUnusedContent, .m_removeAppSupportDirectoryUnusedContent): return .match

case (.m_delete__blocks_blockscourseId_courseId(let lhsBlocks, let lhsCourseid), .m_delete__blocks_blockscourseId_courseId(let rhsBlocks, let rhsCourseid)):
var results: [Matcher.ParameterComparisonResult] = []
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsBlocks, rhs: rhsBlocks, with: matcher), lhsBlocks, rhsBlocks, "blocks"))
results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsCourseid, rhs: rhsCourseid, with: matcher), lhsCourseid, rhsCourseid, "courseId"))
return Matcher.ComparisonResult(results)
case (.p_currentDownloadTask_get,.p_currentDownloadTask_get): return Matcher.ComparisonResult.match
default: return .none
}
Expand All @@ -3685,13 +3699,13 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {
case let .m_cancelDownloading__task_task(p0): return p0.intValue
case let .m_cancelDownloading__courseId_courseId(p0): return p0.intValue
case .m_cancelAllDownloading: return 0
case let .m_deleteFile__blocks_blocks(p0): return p0.intValue
case .m_deleteAllFiles: return 0
case .m_deleteAll: return 0
case let .m_fileUrl__for_blockId(p0): return p0.intValue
case let .m_updateUnzippedFileSize__for_sequentials(p0): return p0.intValue
case .m_resumeDownloading: return 0
case let .m_isLargeVideosSize__blocks_blocks(p0): return p0.intValue
case .m_removeAppSupportDirectoryUnusedContent: return 0
case let .m_delete__blocks_blockscourseId_courseId(p0, p1): return p0.intValue + p1.intValue
case .p_currentDownloadTask_get: return 0
}
}
Expand All @@ -3706,13 +3720,13 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {
case .m_cancelDownloading__task_task: return ".cancelDownloading(task:)"
case .m_cancelDownloading__courseId_courseId: return ".cancelDownloading(courseId:)"
case .m_cancelAllDownloading: return ".cancelAllDownloading()"
case .m_deleteFile__blocks_blocks: return ".deleteFile(blocks:)"
case .m_deleteAllFiles: return ".deleteAllFiles()"
case .m_deleteAll: return ".deleteAll()"
case .m_fileUrl__for_blockId: return ".fileUrl(for:)"
case .m_updateUnzippedFileSize__for_sequentials: return ".updateUnzippedFileSize(for:)"
case .m_resumeDownloading: return ".resumeDownloading()"
case .m_isLargeVideosSize__blocks_blocks: return ".isLargeVideosSize(blocks:)"
case .m_removeAppSupportDirectoryUnusedContent: return ".removeAppSupportDirectoryUnusedContent()"
case .m_delete__blocks_blockscourseId_courseId: return ".delete(blocks:courseId:)"
case .p_currentDownloadTask_get: return "[get] .currentDownloadTask"
}
}
Expand Down Expand Up @@ -3874,13 +3888,13 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {
public static func cancelDownloading(task: Parameter<DownloadDataTask>) -> Verify { return Verify(method: .m_cancelDownloading__task_task(`task`))}
public static func cancelDownloading(courseId: Parameter<String>) -> Verify { return Verify(method: .m_cancelDownloading__courseId_courseId(`courseId`))}
public static func cancelAllDownloading() -> Verify { return Verify(method: .m_cancelAllDownloading)}
public static func deleteFile(blocks: Parameter<[CourseBlock]>) -> Verify { return Verify(method: .m_deleteFile__blocks_blocks(`blocks`))}
public static func deleteAllFiles() -> Verify { return Verify(method: .m_deleteAllFiles)}
public static func deleteAll() -> Verify { return Verify(method: .m_deleteAll)}
public static func fileUrl(for blockId: Parameter<String>) -> Verify { return Verify(method: .m_fileUrl__for_blockId(`blockId`))}
public static func updateUnzippedFileSize(for sequentials: Parameter<[CourseSequential]>) -> Verify { return Verify(method: .m_updateUnzippedFileSize__for_sequentials(`sequentials`))}
public static func resumeDownloading() -> Verify { return Verify(method: .m_resumeDownloading)}
public static func isLargeVideosSize(blocks: Parameter<[CourseBlock]>) -> Verify { return Verify(method: .m_isLargeVideosSize__blocks_blocks(`blocks`))}
public static func removeAppSupportDirectoryUnusedContent() -> Verify { return Verify(method: .m_removeAppSupportDirectoryUnusedContent)}
public static func delete(blocks: Parameter<[CourseBlock]>, courseId: Parameter<String>) -> Verify { return Verify(method: .m_delete__blocks_blockscourseId_courseId(`blocks`, `courseId`))}
public static var currentDownloadTask: Verify { return Verify(method: .p_currentDownloadTask_get) }
}

Expand Down Expand Up @@ -3915,11 +3929,8 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {
public static func cancelAllDownloading(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_cancelAllDownloading, performs: perform)
}
public static func deleteFile(blocks: Parameter<[CourseBlock]>, perform: @escaping ([CourseBlock]) -> Void) -> Perform {
return Perform(method: .m_deleteFile__blocks_blocks(`blocks`), performs: perform)
}
public static func deleteAllFiles(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_deleteAllFiles, performs: perform)
public static func deleteAll(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_deleteAll, performs: perform)
}
public static func fileUrl(for blockId: Parameter<String>, perform: @escaping (String) -> Void) -> Perform {
return Perform(method: .m_fileUrl__for_blockId(`blockId`), performs: perform)
Expand All @@ -3936,6 +3947,9 @@ open class DownloadManagerProtocolMock: DownloadManagerProtocol, Mock {
public static func removeAppSupportDirectoryUnusedContent(perform: @escaping () -> Void) -> Perform {
return Perform(method: .m_removeAppSupportDirectoryUnusedContent, performs: perform)
}
public static func delete(blocks: Parameter<[CourseBlock]>, courseId: Parameter<String>, perform: @escaping ([CourseBlock], String) -> Void) -> Perform {
return Perform(method: .m_delete__blocks_blockscourseId_courseId(`blocks`, `courseId`), performs: perform)
}
}

public func given(_ method: Given) {
Expand Down
4 changes: 4 additions & 0 deletions Core/Core/Analytics/CoreAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ public enum AnalyticsEvent: String {
case courseViewCertificateClicked = "Course:View Certificate Clicked"
case bulkDownloadVideosToggle = "Video:Bulk Download Toggle"
case bulkDownloadVideosSubsection = "Video:Bulk Download Subsection"
case bulkDownloadVideosSection = "Video:Bulk Download Section"
case bulkDeleteVideosSubsection = "Videos:Delete Subsection Videos"
case bulkDeleteVideosSection = "Videos:Delete Section Videos"
case discussionAllPostsClicked = "Discussion:All Posts Clicked"
case discussionFollowingClicked = "Discussion:Following Posts Clicked"
case discussionTopicClicked = "Discussion:Topic Clicked"
Expand Down Expand Up @@ -188,6 +190,8 @@ public enum EventBIValue: String {
case bulkDownloadVideosToggle = "edx.bi.app.videos.download.toggle"
case bulkDownloadVideosSubsection = "edx.bi.video.subsection.bulkdownload"
case bulkDeleteVideosSubsection = "edx.bi.app.video.delete.subsection"
case bulkDownloadVideosSection = "edx.bi.video.section.bulkdownload"
case bulkDeleteVideosSection = "edx.bi.app.video.delete.section"
case dashboardCourseClicked = "edx.bi.app.course.dashboard"
case courseOutlineVideosTabClicked = "edx.bi.app.course.video_tab"
case courseOutlineOfflineTabClicked = "edx.bi.app.course.offline_tab"
Expand Down
8 changes: 6 additions & 2 deletions Core/Core/Data/Model/Data_Media.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import Foundation
public extension DataLayer {

// MARK: - CourseMedia
struct CourseMedia: Decodable, Sendable {
struct CourseMedia: Decodable, Sendable, Equatable {
public static func == (lhs: DataLayer.CourseMedia, rhs: DataLayer.CourseMedia) -> Bool {
lhs.image == rhs.image
}

public let image: DataLayer.Image

public init(image: DataLayer.Image) {
Expand Down Expand Up @@ -61,7 +65,7 @@ public extension DataLayer {

public extension DataLayer {
// MARK: - Image
struct Image: Codable, Sendable {
struct Image: Codable, Sendable, Equatable {
public let raw: String
public let small: String
public let large: String
Expand Down
19 changes: 8 additions & 11 deletions Core/Core/Data/Persistence/CorePersistenceProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,31 @@ public protocol CorePersistenceProtocol: Sendable {
func set(userId: Int)
func getUserID() -> Int?
@MainActor func publisher() throws -> AnyPublisher<Int, Never>
func addToDownloadQueue(tasks: [DownloadDataTask]) async
func addToDownloadQueue(tasks: [DownloadDataTask])
func saveOfflineProgress(progress: OfflineProgress) async
func loadProgress(for blockID: String) async -> OfflineProgress?
func loadAllOfflineProgress() async -> [OfflineProgress]
func deleteProgress(for blockID: String) async
func deleteAllProgress() async

func addToDownloadQueue(blocks: [CourseBlock], downloadQuality: DownloadQuality) async
func nextBlockForDownloading() async -> DownloadDataTask?
func updateDownloadState(id: String, state: DownloadState, resumeData: Data?) async
func deleteDownloadDataTask(id: String) async throws
func addToDownloadQueue(blocks: [CourseBlock], downloadQuality: DownloadQuality)
func updateDownloadState(id: String, state: DownloadState, resumeData: Data?)
func saveDownloadDataTask(_ task: DownloadDataTask) async
func downloadDataTask(for blockId: String) async -> DownloadDataTask?
func getDownloadDataTasks() async -> [DownloadDataTask]
func getDownloadDataTasksForCourse(_ courseId: String) async -> [DownloadDataTask]
func deleteDownloadDataTasks(ids: [String])
}

#if DEBUG
public final class CorePersistenceMock: CorePersistenceProtocol, @unchecked Sendable {

public init() {}
public func set(userId: Int) {}
public func getUserID() -> Int? {1}
public func publisher() -> AnyPublisher<Int, Never> { Just(0).eraseToAnyPublisher() }
public func addToDownloadQueue(blocks: [CourseBlock], downloadQuality: DownloadQuality) async {}
public func addToDownloadQueue(tasks: [DownloadDataTask]) async {}
public func nextBlockForDownloading() async -> DownloadDataTask? { nil }
public func updateDownloadState(id: String, state: DownloadState, resumeData: Data?) async {}
public func deleteDownloadDataTask(id: String) async throws {}
public func addToDownloadQueue(blocks: [CourseBlock], downloadQuality: DownloadQuality) {}
public func addToDownloadQueue(tasks: [DownloadDataTask]) {}
public func updateDownloadState(id: String, state: DownloadState, resumeData: Data?) {}
public func downloadDataTask(for blockId: String) async -> DownloadDataTask? { nil }
public func saveOfflineProgress(progress: OfflineProgress) async {}
public func loadProgress(for blockID: String) async -> OfflineProgress? { nil }
Expand All @@ -51,6 +47,7 @@ public final class CorePersistenceMock: CorePersistenceProtocol, @unchecked Send
public func saveDownloadDataTask(_ task: DownloadDataTask) async {}
public func getDownloadDataTasks() async -> [DownloadDataTask] {[]}
public func getDownloadDataTasksForCourse(_ courseId: String) async -> [DownloadDataTask] {[]}
public func deleteDownloadDataTasks(ids: [String]) {}
}
#endif

Expand Down
16 changes: 12 additions & 4 deletions Core/Core/Domain/Model/CourseBlockModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ public struct CourseProgress: Sendable {
}
}

public struct CourseChapter: Identifiable, Sendable {
public struct CourseChapter: Identifiable, Sendable, Equatable {
public static func == (lhs: CourseChapter, rhs: CourseChapter) -> Bool {
lhs.id == rhs.id &&
lhs.blockId == rhs.blockId
}

public let blockId: String
public let id: String
Expand All @@ -114,7 +118,11 @@ public struct CourseChapter: Identifiable, Sendable {
}
}

public struct CourseSequential: Identifiable, Sendable {
public struct CourseSequential: Identifiable, Sendable, Equatable {
public static func == (lhs: CourseSequential, rhs: CourseSequential) -> Bool {
lhs.id == rhs.id &&
lhs.blockId == rhs.blockId
}

public let blockId: String
public let id: String
Expand Down Expand Up @@ -154,7 +162,7 @@ public struct CourseSequential: Identifiable, Sendable {
}
}

public struct CourseVertical: Identifiable, Hashable, Sendable {
public struct CourseVertical: Identifiable, Hashable, Sendable, Equatable {
public func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
Expand Down Expand Up @@ -215,7 +223,7 @@ public struct SequentialProgress: Sendable {
}
}

public struct CourseBlock: Hashable, Identifiable, Sendable {
public struct CourseBlock: Hashable, Identifiable, Sendable, Equatable {
public static func == (lhs: CourseBlock, rhs: CourseBlock) -> Bool {
lhs.id == rhs.id &&
lhs.blockId == rhs.blockId &&
Expand Down
Loading