From 64cf3b07a2fb88ee92709d9ab280396724d70333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanpe=20Catala=CC=81n?= Date: Thu, 20 Feb 2020 21:40:52 +0100 Subject: [PATCH 1/2] not replace original datasource is running XCTests --- SkeletonView.xcodeproj/project.pbxproj | 6 ++++++ Sources/Collections/UIView+CollectionSkeleton.swift | 9 ++++++--- Sources/Extensions/ProcessInfo+XCTest.swift | 13 +++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 Sources/Extensions/ProcessInfo+XCTest.swift diff --git a/SkeletonView.xcodeproj/project.pbxproj b/SkeletonView.xcodeproj/project.pbxproj index 929045ee..f3a44acd 100644 --- a/SkeletonView.xcodeproj/project.pbxproj +++ b/SkeletonView.xcodeproj/project.pbxproj @@ -30,6 +30,8 @@ 17DD0E1F207FB32100C56334 /* RecursiveProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5307E311FB0F42F00EE67C5 /* RecursiveProtocol.swift */; }; 1E6C67A2230E76CC0019D87B /* SkeletonTransitionStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4CE587C22EEE65200333067 /* SkeletonTransitionStyle.swift */; }; 1E6C67A3230E76CE0019D87B /* UIView+Transitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4CE587B22EEE63100333067 /* UIView+Transitions.swift */; }; + 1EE42E1F23FF25CC00BF665A /* ProcessInfo+XCTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE42E1E23FF25CC00BF665A /* ProcessInfo+XCTest.swift */; }; + 1EE42E2023FF25CC00BF665A /* ProcessInfo+XCTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE42E1E23FF25CC00BF665A /* ProcessInfo+XCTest.swift */; }; 42ABD063210B548200BEEFF4 /* SkeletonView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52D6D97C1BEFF229002C0205 /* SkeletonView.framework */; }; 42ABD069210B548200BEEFF4 /* SkeletonView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 52D6D97C1BEFF229002C0205 /* SkeletonView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 42ABD078210B54E200BEEFF4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42ABD070210B54E100BEEFF4 /* AppDelegate.swift */; }; @@ -156,6 +158,7 @@ 17DD0E00207FB27400C56334 /* SkeletonView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SkeletonView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 17DD0E1A207FB2C200C56334 /* SkeletonView-tvOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SkeletonView-tvOS.plist"; sourceTree = ""; }; 17DD0E1B207FB2C200C56334 /* SkeletonView-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SkeletonView-iOS.plist"; sourceTree = ""; }; + 1EE42E1E23FF25CC00BF665A /* ProcessInfo+XCTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProcessInfo+XCTest.swift"; sourceTree = ""; }; 42ABD06D210B548200BEEFF4 /* SkeletonViewExampleUICollectionView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SkeletonViewExampleUICollectionView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42ABD070210B54E100BEEFF4 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 42ABD071210B54E100BEEFF4 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; @@ -438,6 +441,7 @@ F5804771230ECD0000066D02 /* UIView+IBInspectable.swift */, F587FB85202CEC95002DB5FE /* UIView+UIApplicationDelegate.swift */, 5600784323FD293D00669AD6 /* UITableView+VisibleSections.swift */, + 1EE42E1E23FF25CC00BF665A /* ProcessInfo+XCTest.swift */, ); path = Extensions; sourceTree = ""; @@ -691,6 +695,7 @@ F51ED28320973CBB008B2434 /* SkeletonCollectionDelegate.swift in Sources */, F58A6E6F20A8C66300612494 /* Recoverable.swift in Sources */, 17DD0E18207FB28F00C56334 /* SkeletonView.swift in Sources */, + 1EE42E2023FF25CC00BF665A /* ProcessInfo+XCTest.swift in Sources */, 17DD0E19207FB28F00C56334 /* SkeletonFlow.swift in Sources */, 17DD0E09207FB28900C56334 /* SkeletonCollectionDataSource.swift in Sources */, 17DD0E0C207FB28900C56334 /* UICollectionView+CollectionSkeleton.swift in Sources */, @@ -750,6 +755,7 @@ F5F899ED1FAB9F04002E8FDA /* CollectionSkeletonProtocol.swift in Sources */, F58A6E6E20A8C66300612494 /* Recoverable.swift in Sources */, F5307E2C1FAF6BC900EE67C5 /* SkeletonGradient.swift in Sources */, + 1EE42E1F23FF25CC00BF665A /* ProcessInfo+XCTest.swift in Sources */, F587FB86202CEC95002DB5FE /* UIView+UIApplicationDelegate.swift in Sources */, F5F899EB1FAB9DA3002E8FDA /* SkeletonCollectionDataSource.swift in Sources */, F5F622411FAC6E31007C062A /* UIColor+Skeleton.swift in Sources */, diff --git a/Sources/Collections/UIView+CollectionSkeleton.swift b/Sources/Collections/UIView+CollectionSkeleton.swift index a293aeb1..42fe9599 100644 --- a/Sources/Collections/UIView+CollectionSkeleton.swift +++ b/Sources/Collections/UIView+CollectionSkeleton.swift @@ -10,19 +10,22 @@ import UIKit extension UIView { func addDummyDataSourceIfNeeded() { - guard let collection = self as? CollectionSkeleton else { return } + guard let collection = self as? CollectionSkeleton, + !ProcessInfo.isRunningXCTest else { return } status = .on collection.addDummyDataSource() collection.disableUserInteraction() } func updateDummyDataSourceIfNeeded() { - guard let collection = self as? CollectionSkeleton else { return } + guard let collection = self as? CollectionSkeleton, + !ProcessInfo.isRunningXCTest else { return } collection.updateDummyDataSource() } func removeDummyDataSourceIfNeeded(reloadAfter reload: Bool = true) { - guard let collection = self as? CollectionSkeleton else { return } + guard let collection = self as? CollectionSkeleton, + !ProcessInfo.isRunningXCTest else { return } status = .off collection.removeDummyDataSource(reloadAfter: reload) collection.enableUserInteraction() diff --git a/Sources/Extensions/ProcessInfo+XCTest.swift b/Sources/Extensions/ProcessInfo+XCTest.swift new file mode 100644 index 00000000..d5c6166b --- /dev/null +++ b/Sources/Extensions/ProcessInfo+XCTest.swift @@ -0,0 +1,13 @@ +// Copyright © 2020 SkeletonView. All rights reserved. + +import Foundation + +extension ProcessInfo { + enum Constants { + static let testConfigurationFilePathKey = "XCTestConfigurationFilePath" + } + + static var isRunningXCTest: Bool { + return processInfo.environment[Constants.testConfigurationFilePathKey] != nil + } +} From 6fc98f08d13e67d7fd1a8b3e2ea486af679c9aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanpe=20Catala=CC=81n?= Date: Thu, 20 Feb 2020 21:43:54 +0100 Subject: [PATCH 2/2] add 264 PR to CHANGELOG file --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5a013f3..243d5220 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,11 @@ All notable changes to this project will be documented in this file * [**242**](https://github.com/Juanpe/SkeletonView/pull/242): Offscreen table view layout issue fixed - [@Cacodemon](https://github.com/Cacodemon) * [**261**](https://github.com/Juanpe/SkeletonView/pull/261): Fixes removing skeleton layers from table header footer sections - [@darkside999](https://github.com/darkside999) * [**263**](https://github.com/Juanpe/SkeletonView/pull/263): Feature/set cross dissolve transitions as default - [@Juanpe](https://github.com/Juanpe) - +* [**264**](https://github.com/Juanpe/SkeletonView/pull/264): not replace original datasource is running XCTests - [@Juanpe](https://github.com/Juanpe) +* #### 🩹 Bug fixes * [**260**](https://github.com/Juanpe/SkeletonView/issues/260): Don't hide skeleton layers on TableViewHeaderFooterView +* [**257**](https://github.com/Juanpe/SkeletonView/issues/257): Unit test problem when using SkeletonView