From 62942c21226930bb7637123fb477b4c53e05f894 Mon Sep 17 00:00:00 2001 From: RomanTysiachnik Date: Tue, 29 Jan 2019 14:11:20 +0200 Subject: [PATCH] Dropped boilerplate code for Hashable and Equatable --- PlayerCore | 2 +- VerizonVideoPartnerSDK.xcodeproj/project.pbxproj | 4 ---- VideoRenderer | 2 +- sources/advertisements/AdManagerPresenter.swift | 16 ---------------- sources/advertisements/MidrollDetector.swift | 15 +-------------- sources/advertisements/VRMProvider.swift | 4 ++-- .../ad view time/AdViewTimeDetector.swift | 2 +- .../ad view time/AdViewTimeDetectorTests.swift | 9 --------- sources/player/PlayerActionsJSONTests.swift | 13 ------------- sources/player/VideoSelector.swift | 2 +- 10 files changed, 7 insertions(+), 62 deletions(-) delete mode 100644 sources/player/PlayerActionsJSONTests.swift diff --git a/PlayerCore b/PlayerCore index 43342ed..18c3a1f 160000 --- a/PlayerCore +++ b/PlayerCore @@ -1 +1 @@ -Subproject commit 43342edfc774f5d3f04819a3af70818d4fd189ef +Subproject commit 18c3a1f01fe02a2ea96023d04c21de550dd6a3e7 diff --git a/VerizonVideoPartnerSDK.xcodeproj/project.pbxproj b/VerizonVideoPartnerSDK.xcodeproj/project.pbxproj index 47e2eb0..9688f81 100644 --- a/VerizonVideoPartnerSDK.xcodeproj/project.pbxproj +++ b/VerizonVideoPartnerSDK.xcodeproj/project.pbxproj @@ -221,7 +221,6 @@ DE4C51C61C8094FE00BFFB0B /* MetricsSender.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4C51531C80731B00BFFB0B /* MetricsSender.swift */; }; DE4C51D71C80957B00BFFB0B /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4C51D51C80957B00BFFB0B /* Player.swift */; }; DE4C51E11C80D43200BFFB0B /* TrackingPixelsConnector.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4C51E01C80D43200BFFB0B /* TrackingPixelsConnector.swift */; }; - DE5F27E11F44501E00011E2C /* PlayerActionsJSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE5F27E01F44501E00011E2C /* PlayerActionsJSONTests.swift */; }; DE684CD71E0C2F36007CE35C /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE684CD61E0C2F36007CE35C /* Action.swift */; }; DE684CD81E0C2F36007CE35C /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE684CD61E0C2F36007CE35C /* Action.swift */; }; DE684CDC1E0EBFC3007CE35C /* SystemPlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5067F5FE1D49120E00FEC27C /* SystemPlayerViewController.swift */; }; @@ -591,7 +590,6 @@ DE4C51D51C80957B00BFFB0B /* Player.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Player.swift; sourceTree = ""; }; DE4C51D61C80957B00BFFB0B /* ObserverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ObserverTests.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; DE4C51E01C80D43200BFFB0B /* TrackingPixelsConnector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackingPixelsConnector.swift; sourceTree = ""; }; - DE5F27E01F44501E00011E2C /* PlayerActionsJSONTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerActionsJSONTests.swift; sourceTree = ""; }; DE611A791E9D40F200D253B2 /* PlayerControls.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PlayerControls.xcodeproj; path = PlayerControls/PlayerControls/PlayerControls.xcodeproj; sourceTree = ""; }; DE684CD61E0C2F36007CE35C /* Action.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Action.swift; sourceTree = ""; }; DE79CE201E979F9700C3A660 /* AdURLProviderProcess.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdURLProviderProcess.swift; sourceTree = ""; }; @@ -1009,7 +1007,6 @@ children = ( 50E5ADE71EE0428A004104D6 /* PlayerTracer.playground */, 50E5ADE81EE08A76004104D6 /* PlayerTracer.swift */, - DE5F27E01F44501E00011E2C /* PlayerActionsJSONTests.swift */, ); name = tracer; sourceTree = ""; @@ -1998,7 +1995,6 @@ E22B6AD921EF852800D480A0 /* VRMProcessingControllerTest.swift in Sources */, FE940A001F3DD56600A867CD /* IntentDetectorTests.swift in Sources */, 50A12D031CE639160088A74E /* NetworkTests.swift in Sources */, - DE5F27E11F44501E00011E2C /* PlayerActionsJSONTests.swift in Sources */, 50D747891CE624E200CB91D4 /* VRMRequestTests.swift in Sources */, 061CFFFC211C7263002B5BE9 /* MuteDetectorTests.swift in Sources */, 508A597E2010F97B00641398 /* VRMDetectorTests.swift in Sources */, diff --git a/VideoRenderer b/VideoRenderer index f53d9f5..cdc73bd 160000 --- a/VideoRenderer +++ b/VideoRenderer @@ -1 +1 @@ -Subproject commit f53d9f531ce0ed70c3912c542d69eee7ee6a3d5d +Subproject commit cdc73bdb1b086bcf6f1c181ebf99ff864a291b26 diff --git a/sources/advertisements/AdManagerPresenter.swift b/sources/advertisements/AdManagerPresenter.swift index ca2419e..8a4a695 100644 --- a/sources/advertisements/AdManagerPresenter.swift +++ b/sources/advertisements/AdManagerPresenter.swift @@ -71,19 +71,3 @@ final class AdManager { } } } - -extension VRMProvider.Item: Hashable { - var hashValue: Int { - switch self { - case let .vast(string, _): return string.hashValue - case let .url(url, _): return url.hashValue - } - } -} - -func == (left: VRMProvider.Item, right: VRMProvider.Item) -> Bool { - switch (left, right) { - case (let .vast(lh, _), let .vast(rh, _)): return lh == rh - case (let .url(lh, _), let .url(rh, _)): return lh == rh - default: return false } -} diff --git a/sources/advertisements/MidrollDetector.swift b/sources/advertisements/MidrollDetector.swift index e1bfd04..1f20143 100644 --- a/sources/advertisements/MidrollDetector.swift +++ b/sources/advertisements/MidrollDetector.swift @@ -48,7 +48,7 @@ func playAction(input: MidrollDetector.Input, class MidrollDetector { typealias Midroll = PlayerCore.Ad.Midroll - enum Action { + enum Action: Hashable { case prefetch(Midroll) case play(PlayerCore.Ad.VASTModel?, Midroll) } @@ -138,16 +138,3 @@ extension MidrollDetector.Input { hasActiveAds = item.hasActiveAds } } - - -extension MidrollDetector.Action: Equatable { - static func ==(lhs: MidrollDetector.Action, rhs: MidrollDetector.Action) -> Bool { - switch (lhs, rhs) { - case (.prefetch(let lhsMidroll), .prefetch(let rhsMidroll)): - return lhsMidroll == rhsMidroll - case (.play(let lhsPrefetchedModel, let lhsPrefetchedMidroll), .play(let rhsPrefetchedModel, let rhsPrefetchedMidroll)): - return lhsPrefetchedModel == rhsPrefetchedModel && lhsPrefetchedMidroll == rhsPrefetchedMidroll - default: return false - } - } -} diff --git a/sources/advertisements/VRMProvider.swift b/sources/advertisements/VRMProvider.swift index c55ed12..1338676 100644 --- a/sources/advertisements/VRMProvider.swift +++ b/sources/advertisements/VRMProvider.swift @@ -50,8 +50,8 @@ struct VRMProvider { throw Error.CannotExtractAdEngineFromJSON(json) } - enum Item { - struct MetaInfo { + enum Item: Hashable { + struct MetaInfo: Hashable { let engineType: String? let ruleId: String? let ruleCompanyId: String? diff --git a/sources/metrics/detectors/ad view time/AdViewTimeDetector.swift b/sources/metrics/detectors/ad view time/AdViewTimeDetector.swift index 27c0d47..1847746 100644 --- a/sources/metrics/detectors/ad view time/AdViewTimeDetector.swift +++ b/sources/metrics/detectors/ad view time/AdViewTimeDetector.swift @@ -10,7 +10,7 @@ extension Detectors { var isProcessed = false var timePlayed: Double = 0 - struct Result { + struct Result: Hashable { let duration: Double let time: Double let videoIndex: Int diff --git a/sources/metrics/detectors/ad view time/AdViewTimeDetectorTests.swift b/sources/metrics/detectors/ad view time/AdViewTimeDetectorTests.swift index 6ad1fb4..082e5f8 100644 --- a/sources/metrics/detectors/ad view time/AdViewTimeDetectorTests.swift +++ b/sources/metrics/detectors/ad view time/AdViewTimeDetectorTests.swift @@ -108,12 +108,3 @@ class AdViewTimeDetectorTests: XCTestCase { } } - -extension Detectors.AdViewTime.Result: Equatable { - public static func ==(lhs: Detectors.AdViewTime.Result, rhs: Detectors.AdViewTime.Result) -> Bool { - return lhs.duration == rhs.duration - && lhs.time == rhs.time - && lhs.videoIndex == rhs.videoIndex - && lhs.vvuid == rhs.vvuid - } -} diff --git a/sources/player/PlayerActionsJSONTests.swift b/sources/player/PlayerActionsJSONTests.swift deleted file mode 100644 index 95003f4..0000000 --- a/sources/player/PlayerActionsJSONTests.swift +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018, Oath Inc. -// Licensed under the terms of the MIT License. See LICENSE.md file in project root for terms. - -import XCTest -import CoreMedia -import PlayerCore -@testable import VerizonVideoPartnerSDK - -extension VideoSelector: Equatable { - public static func ==(lhs: VideoSelector, rhs: VideoSelector) -> Bool { - return lhs.index == rhs.index - } -} diff --git a/sources/player/VideoSelector.swift b/sources/player/VideoSelector.swift index 1a807b8..5ead77c 100644 --- a/sources/player/VideoSelector.swift +++ b/sources/player/VideoSelector.swift @@ -1,7 +1,7 @@ // Copyright © 2018 Oath Inc // Licensed under the terms of the MIT License. See LICENSE.md file in project root for terms. -struct VideoSelector { +struct VideoSelector: Equatable { let index: Int init(index: Int, currentIndex: Int?, playlistCount: Int) throws {