lottie-ios 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.github/workflows/main.yml +0 -2
  2. package/README.md +0 -7
  3. package/lottie-ios.podspec +1 -1
  4. package/package.json +1 -1
  5. package/.gitattributes +0 -1
  6. package/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +0 -7
  7. package/.swiftpm/xcode/package.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  8. package/.swiftpm/xcode/package.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  9. package/.swiftpm/xcode/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +0 -67
  10. package/.swiftpm/xcode/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  11. package/Tests/AnimationCacheProviderTests.swift +0 -40
  12. package/Tests/AnimationKeypathTests.swift +0 -110
  13. package/Tests/AnimationViewTests.swift +0 -64
  14. package/Tests/AutomaticEngineTests.swift +0 -67
  15. package/Tests/BundleTests.swift +0 -25
  16. package/Tests/DataURLTests.swift +0 -64
  17. package/Tests/ParsingTests.swift +0 -45
  18. package/Tests/PerformanceTests.swift +0 -214
  19. package/Tests/SnapshotConfiguration.swift +0 -172
  20. package/Tests/SnapshotTests.swift +0 -299
  21. package/Tests/Utils/Bundle+Module.swift +0 -30
  22. package/Tests/Utils/HardcodedFontProvider.swift +0 -19
  23. package/Tests/Utils/HardcodedImageProvider.swift +0 -23
  24. package/Tests/Utils/HardcodedTextProvider.swift +0 -27
  25. package/Tests/Utils/Snapshotting+presentationLayer.swift +0 -47
  26. package/Tests/ValueProvidersTests.swift +0 -30
  27. package/script/test-carthage/Cartfile +0 -1
  28. package/script/test-carthage/Cartfile.resolved +0 -1
  29. package/script/test-carthage/CarthageTest/AppDelegate.swift +0 -26
  30. package/script/test-carthage/CarthageTest/Assets.xcassets/AccentColor.colorset/Contents.json +0 -11
  31. package/script/test-carthage/CarthageTest/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -98
  32. package/script/test-carthage/CarthageTest/Assets.xcassets/Contents.json +0 -6
  33. package/script/test-carthage/CarthageTest/Base.lproj/LaunchScreen.storyboard +0 -25
  34. package/script/test-carthage/CarthageTest/Base.lproj/Main.storyboard +0 -24
  35. package/script/test-carthage/CarthageTest/Info.plist +0 -66
  36. package/script/test-carthage/CarthageTest/SceneDelegate.swift +0 -10
  37. package/script/test-carthage/CarthageTest/ViewController.swift +0 -15
  38. package/script/test-carthage/CarthageTest-macOS/AppDelegate.swift +0 -7
  39. package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/AccentColor.colorset/Contents.json +0 -11
  40. package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -58
  41. package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/Contents.json +0 -6
  42. package/script/test-carthage/CarthageTest-macOS/Base.lproj/Main.storyboard +0 -717
  43. package/script/test-carthage/CarthageTest-macOS/CarthageTest_macOS.entitlements +0 -10
  44. package/script/test-carthage/CarthageTest-macOS/ViewController.swift +0 -15
  45. package/script/test-carthage/CarthageTest.xcodeproj/project.pbxproj +0 -532
  46. package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  47. package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  48. package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  49. package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  50. package/script/test-carthage/CarthageTest.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  51. package/script/test-carthage/CarthageTest.xcodeproj/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +0 -19
  52. package/script/test-carthage/Mintfile +0 -1
  53. package/script/test-spm/LottieSPM.xcworkspace/contents.xcworkspacedata +0 -7
  54. package/script/test-spm/LottieSPM.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  55. package/script/test-spm/Mintfile +0 -1
@@ -39,8 +39,6 @@ jobs:
39
39
  runs-on: macos-12
40
40
  steps:
41
41
  - uses: actions/checkout@v2
42
- with:
43
- lfs: 'true'
44
42
  - uses: ./.github/actions/setup
45
43
  - name: Test Package
46
44
  run: bundle exec rake test:package
package/README.md CHANGED
@@ -75,13 +75,6 @@ We always appreciate contributions from the community. To make changes to the pr
75
75
  - unit tests and snapshot tests (for iOS, must be run on an iPhone 8 simulator)
76
76
  - an Example iOS app that lets you browse and test over 100 sample animations included in the repo
77
77
 
78
- To reduce the size of the repository, snapshot images are stored using [Git Large File Storage](https://git-lfs.github.com/). Before running the snapshot tests, you'll need to install Git LFS:
79
-
80
- ```bash
81
- $ brew install git-lfs
82
- $ git lfs install
83
- ```
84
-
85
78
  All pull requests with new features or bug fixes that affect how animations render should include snapshot test cases that validate the included changes.
86
79
  - To add a new sample animation to the snapshot testing suite, you can add the `.json` file to `Tests/Samples`. Re-run the snapshot tests to generate the new snapshot image files.
87
80
  - To update existing snapshots after making changes, you can set `isRecording = true` in `SnapshotTests.swift` and then re-run the snapshot tests.
@@ -8,7 +8,7 @@
8
8
 
9
9
  Pod::Spec.new do |s|
10
10
  s.name = 'lottie-ios'
11
- s.version = '4.0.0'
11
+ s.version = '4.0.1'
12
12
  s.summary = 'A library to render native animations from bodymovin json'
13
13
 
14
14
  s.description = <<-DESC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lottie-ios",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with bodymovin and renders the vector animations natively on mobile and through React Native!",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/.gitattributes DELETED
@@ -1 +0,0 @@
1
- Tests/__Snapshots__/SnapshotTests/** filter=lfs diff=lfs merge=lfs -text
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- <FileRef
5
- location = "self:">
6
- </FileRef>
7
- </Workspace>
@@ -1,67 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>Lottie-Package.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- <key>Lottie.xcscheme_^#shared#^_</key>
13
- <dict>
14
- <key>orderHint</key>
15
- <integer>0</integer>
16
- </dict>
17
- <key>_LottieCore.xcscheme_^#shared#^_</key>
18
- <dict>
19
- <key>orderHint</key>
20
- <integer>2</integer>
21
- </dict>
22
- </dict>
23
- <key>SuppressBuildableAutocreation</key>
24
- <dict>
25
- <key>Lottie</key>
26
- <dict>
27
- <key>primary</key>
28
- <true/>
29
- </dict>
30
- <key>Lottie Tests</key>
31
- <dict>
32
- <key>primary</key>
33
- <true/>
34
- </dict>
35
- <key>LottieCarthage</key>
36
- <dict>
37
- <key>primary</key>
38
- <true/>
39
- </dict>
40
- <key>LottieCore</key>
41
- <dict>
42
- <key>primary</key>
43
- <true/>
44
- </dict>
45
- <key>LottieTests</key>
46
- <dict>
47
- <key>primary</key>
48
- <true/>
49
- </dict>
50
- <key>Lottie_LottieTests</key>
51
- <dict>
52
- <key>primary</key>
53
- <true/>
54
- </dict>
55
- <key>_LottieCore</key>
56
- <dict>
57
- <key>primary</key>
58
- <true/>
59
- </dict>
60
- <key>_LottieDynamic</key>
61
- <dict>
62
- <key>primary</key>
63
- <true/>
64
- </dict>
65
- </dict>
66
- </dict>
67
- </plist>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>Lottie.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>6</integer>
11
- </dict>
12
- </dict>
13
- </dict>
14
- </plist>
@@ -1,40 +0,0 @@
1
- //
2
- // AnimationCacheProviderTests.swift
3
- // LottieTests
4
- //
5
- // Created by Marcelo Fabri on 10/18/22.
6
- //
7
-
8
- import XCTest
9
-
10
- @testable import Lottie
11
-
12
- final class AnimationCacheProviderTests: XCTestCase {
13
-
14
- func testCaches() throws {
15
- let cache = DefaultAnimationCache()
16
- let animation1 = try XCTUnwrap(Samples.animation(named: "Boat_Loader"))
17
- let animation2 = try XCTUnwrap(Samples.animation(named: "TwitterHeart"))
18
-
19
- XCTAssertNil(cache.animation(forKey: "animation1"))
20
- cache.setAnimation(animation1, forKey: "animation1")
21
- XCTAssertNoDiff(cache.animation(forKey: "animation1"), animation1)
22
-
23
- XCTAssertNil(cache.animation(forKey: "animation2"))
24
- cache.setAnimation(animation2, forKey: "animation2")
25
- XCTAssertNoDiff(cache.animation(forKey: "animation2"), animation2)
26
- XCTAssertNoDiff(cache.animation(forKey: "animation1"), animation1)
27
- }
28
-
29
- func testClearCache() throws {
30
- let cache = DefaultAnimationCache()
31
- let animation = try XCTUnwrap(Samples.animation(named: "Boat_Loader"))
32
-
33
- XCTAssertNil(cache.animation(forKey: "animation"))
34
- cache.setAnimation(animation, forKey: "animation")
35
- XCTAssertNotNil(cache.animation(forKey: "animation"))
36
-
37
- cache.clearCache()
38
- XCTAssertNil(cache.animation(forKey: "animation"))
39
- }
40
- }
@@ -1,110 +0,0 @@
1
- // Created by Cal Stephens on 1/24/22.
2
- // Copyright © 2022 Airbnb Inc. All rights reserved.
3
-
4
- import SnapshotTesting
5
- import XCTest
6
-
7
- @testable import Lottie
8
-
9
- @MainActor
10
- final class AnimationKeypathTests: XCTestCase {
11
-
12
- // MARK: Internal
13
-
14
- func testKeypathMatches() {
15
- let keypath = AnimationKeypath(keypath: "Layer.Shape Group.Stroke 1.Color")
16
-
17
- XCTAssertTrue(keypath.matches("Layer.Shape Group.Stroke 1.Color"))
18
- XCTAssertTrue(keypath.matches("**.Color"))
19
- XCTAssertTrue(keypath.matches("**.Stroke 1.Color"))
20
- XCTAssertTrue(keypath.matches("**.Shape Group.Stroke 1.Color"))
21
- XCTAssertTrue(keypath.matches("Layer.**.Color"))
22
- XCTAssertTrue(keypath.matches("Layer.Shape Group.*.Color"))
23
- XCTAssertTrue(keypath.matches("Layer.*.*.Color"))
24
-
25
- XCTAssertFalse(keypath.matches("Layer.*.Color"))
26
- XCTAssertFalse(keypath.matches("**.Layer.Shape Group.Stroke 1.Color"))
27
- XCTAssertFalse(keypath.matches("*.Layer.Shape Group.Stroke 1.Color"))
28
- XCTAssertFalse(keypath.matches("Layer.Shape Group.Stroke 1.Color.*"))
29
- XCTAssertFalse(keypath.matches("Layer.Shape Group.Stroke 1.Color.**"))
30
- }
31
-
32
- func testLayerForKeypath() {
33
- let animationView = LottieAnimationView(
34
- animation: Samples.animation(named: "Boat_Loader"),
35
- configuration: LottieConfiguration(renderingEngine: .mainThread))
36
-
37
- XCTAssertNotNil(animationView.animationLayer?.layer(for: "Success.FishComplete.Fish1Tail 7"))
38
- XCTAssertNotNil(animationView.animationLayer?.layer(for: "Success.FishComplete"))
39
- XCTAssertNotNil(animationView.animationLayer?.layer(for: "Success"))
40
- XCTAssertNotNil(animationView.animationLayer?.layer(for: "Success.*.Fish1Tail 7"))
41
- }
42
-
43
- func testMainThreadEngineKeypathLogging() async {
44
- await snapshotHierarchyKeypaths(
45
- animationName: "Switch",
46
- configuration: LottieConfiguration(renderingEngine: .mainThread))
47
- }
48
-
49
- func testCoreAnimationEngineKeypathLogging() async {
50
- await snapshotHierarchyKeypaths(
51
- animationName: "Switch",
52
- configuration: LottieConfiguration(renderingEngine: .coreAnimation))
53
-
54
- await snapshotHierarchyKeypaths(
55
- animationName: "Issues/issue_1664",
56
- configuration: LottieConfiguration(renderingEngine: .coreAnimation))
57
- }
58
-
59
- /// The Core Animation engine supports a subset of the keypaths supported by the Main Thread engine.
60
- /// All keypaths that are supported in the Core Animation engine should also be supported by the Main Thread engine.
61
- func testCoreAnimationEngineKeypathCompatibility() async {
62
- let mainThreadKeypaths =
63
- Set(await hierarchyKeypaths(animationName: "Switch", configuration: .init(renderingEngine: .mainThread)))
64
- let coreAnimationKeypaths = await hierarchyKeypaths(
65
- animationName: "Switch",
66
- configuration: .init(renderingEngine: .coreAnimation))
67
-
68
- for coreAnimationKeypath in coreAnimationKeypaths {
69
- XCTAssert(
70
- mainThreadKeypaths.contains(coreAnimationKeypath),
71
- """
72
- \(coreAnimationKeypath) from Core Animation rendering engine \
73
- is not supported in Main Thread rendering engine
74
- """)
75
- }
76
- }
77
-
78
- // MARK: Private
79
-
80
- private func snapshotHierarchyKeypaths(
81
- animationName: String,
82
- configuration: LottieConfiguration,
83
- function: String = #function,
84
- line: UInt = #line) async
85
- {
86
- let hierarchyKeypaths = await hierarchyKeypaths(animationName: animationName, configuration: configuration)
87
-
88
- assertSnapshot(
89
- matching: hierarchyKeypaths.sorted().joined(separator: "\n"),
90
- as: .description,
91
- named: animationName,
92
- testName: function,
93
- line: line)
94
- }
95
-
96
- private func hierarchyKeypaths(animationName: String, configuration: LottieConfiguration) async -> [String] {
97
- var printedMessages = [String]()
98
- let logger = LottieLogger(info: { message in
99
- printedMessages.append(message())
100
- })
101
-
102
- let animationView = await SnapshotConfiguration.makeAnimationView(
103
- for: animationName,
104
- configuration: configuration,
105
- logger: logger)
106
- animationView?.logHierarchyKeypaths()
107
- return Array(printedMessages[1...])
108
- }
109
-
110
- }
@@ -1,64 +0,0 @@
1
- // Created by Cal Stephens on 11/11/22.
2
- // Copyright © 2022 Airbnb Inc. All rights reserved.
3
-
4
- import Lottie
5
- import XCTest
6
-
7
- @MainActor
8
- final class AnimationViewTests: XCTestCase {
9
-
10
- func testLoadJsonFile() {
11
- let animationView = LottieAnimationView(
12
- name: "LottieLogo1",
13
- bundle: .module,
14
- subdirectory: Samples.directoryName)
15
-
16
- XCTAssertNotNil(animationView.animation)
17
-
18
- let expectation = XCTestExpectation(description: "animationLoaded is called")
19
- animationView.animationLoaded = { [weak animationView] view, animation in
20
- XCTAssert(animation === view.animation)
21
- XCTAssertEqual(view, animationView)
22
- XCTAssert(Thread.isMainThread)
23
- expectation.fulfill()
24
- }
25
-
26
- wait(for: [expectation], timeout: 0.25)
27
- }
28
-
29
- func testLoadDotLottieFileAsyncWithCompletionClosure() {
30
- let expectation = XCTestExpectation(description: "completion closure is called")
31
-
32
- _ = LottieAnimationView(
33
- dotLottieName: "DotLottie/animation",
34
- bundle: .module,
35
- subdirectory: Samples.directoryName,
36
- completion: { animationView, error in
37
- XCTAssertNil(error)
38
- XCTAssertNotNil(animationView.animation)
39
- XCTAssert(Thread.isMainThread)
40
- expectation.fulfill()
41
- })
42
-
43
- wait(for: [expectation], timeout: 1.0)
44
- }
45
-
46
- func testLoadDotLottieFileAsyncWithDidLoadClosure() {
47
- let expectation = XCTestExpectation(description: "animationLoaded closure is called")
48
-
49
- let animationView = LottieAnimationView(
50
- dotLottieName: "DotLottie/animation",
51
- bundle: .module,
52
- subdirectory: Samples.directoryName)
53
-
54
- animationView.animationLoaded = { [weak animationView] view, animation in
55
- XCTAssert(view.animation === animation)
56
- XCTAssertEqual(view, animationView)
57
- XCTAssert(Thread.isMainThread)
58
- expectation.fulfill()
59
- }
60
-
61
- wait(for: [expectation], timeout: 1.0)
62
- }
63
-
64
- }
@@ -1,67 +0,0 @@
1
- // Created by Cal Stephens on 5/2/22.
2
- // Copyright © 2022 Airbnb Inc. All rights reserved.
3
-
4
- import SnapshotTesting
5
- import UIKit
6
- import XCTest
7
-
8
- @testable import Lottie
9
-
10
- @MainActor
11
- final class AutomaticEngineTests: XCTestCase {
12
-
13
- /// Snapshot tests for whether or not each sample animation supports the Core Animation engine
14
- func testAutomaticEngineDetection() async throws {
15
- for sampleAnimationName in Samples.sampleAnimationNames {
16
- var animation = Samples.animation(named: sampleAnimationName)
17
- if animation == nil {
18
- animation = await Samples.dotLottie(named: sampleAnimationName)?.animations.first?.animation
19
- }
20
-
21
- guard let animation = animation else {
22
- XCTFail("Couldn't load animation named \(sampleAnimationName)")
23
- continue
24
- }
25
-
26
- var compatibilityIssues = [CompatibilityIssue]()
27
-
28
- let animationLayer = try XCTUnwrap(CoreAnimationLayer(
29
- animation: animation,
30
- imageProvider: BundleImageProvider(bundle: Bundle.main, searchPath: nil),
31
- textProvider: DefaultTextProvider(),
32
- fontProvider: DefaultFontProvider(),
33
- compatibilityTrackerMode: .track,
34
- logger: .shared))
35
-
36
- animationLayer.didSetUpAnimation = { issues in
37
- compatibilityIssues = issues
38
- }
39
-
40
- animationLayer.bounds = CGRect(origin: .zero, size: animation.size)
41
- animationLayer.layoutIfNeeded()
42
- animationLayer.display()
43
-
44
- let compatibilityReport: String
45
- if compatibilityIssues.isEmpty {
46
- compatibilityReport = "Supports Core Animation engine"
47
- } else {
48
- compatibilityReport = "Does not support Core Animation engine. Encountered compatibility issues:\n"
49
- + compatibilityIssues.map { $0.description }.joined(separator: "\n")
50
- }
51
-
52
- assertSnapshot(
53
- matching: compatibilityReport,
54
- as: .description,
55
- named: sampleAnimationName)
56
- }
57
- }
58
-
59
- override func setUp() {
60
- LottieLogger.shared = .printToConsole
61
- }
62
-
63
- override func tearDown() {
64
- LottieLogger.shared = LottieLogger()
65
- }
66
-
67
- }
@@ -1,25 +0,0 @@
1
- //
2
- // BundleTests.swift
3
- // LottieTests
4
- //
5
- // Created by Marcelo Fabri on 5/5/22.
6
- //
7
-
8
- import XCTest
9
-
10
- @testable import Lottie
11
-
12
- final class BundleTests: XCTestCase {
13
-
14
- var bundle: Bundle { .module }
15
-
16
- func testGetAnimationDataWithSuffix() throws {
17
- let data = try bundle.getAnimationData("HamburgerArrow.json", subdirectory: "Samples")
18
- XCTAssertNotNil(data)
19
- }
20
-
21
- func testGetAnimationDataWithoutSuffix() throws {
22
- let data = try bundle.getAnimationData("HamburgerArrow", subdirectory: "Samples")
23
- XCTAssertNotNil(data)
24
- }
25
- }
@@ -1,64 +0,0 @@
1
- // Created by Nicholas Mata on 2/23/22.
2
- // Copyright © 2022 Airbnb Inc. All rights reserved.
3
-
4
- import Foundation
5
- import XCTest
6
-
7
- @testable import Lottie
8
-
9
- // MARK: - DataURLTests
10
-
11
- // Tests are based on implementation found here
12
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
13
- final class DataURLTests: XCTestCase {
14
-
15
- let red5x5 =
16
- "%89%50%4e%47%0d%0a%1a%0a%00%00%00%0d%49%48%44%52%00%00%00%05%00%00%00%05%08%06%00%00%00%8d%6f%26%e5%00%00%00%12%49%44%41%54%78%da%63%fc%cf%c0%00%44%a8%80%91%06%82%00%5c%65%09%fc%86%fe%00%b0%00%00%00%00%49%45%4e%44%ae%42%60%82"
17
-
18
- let red5x5Base64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAEklEQVR42mP8z8AARKiAkQaCAFxlCfyG/gCwAAAAAElFTkSuQmCC"
19
-
20
- func testValidDataURL() {
21
- let dataString = "data:image/png;base64,\(red5x5Base64)"
22
-
23
- let data = Data(dataString: dataString)
24
- XCTAssertNotNil(data, "Data should not be nil if valid base64 string")
25
- let image = UIImage(data: data!)
26
- XCTAssertNotNil(image, "Should be valid image")
27
-
28
- // Since legacy options will print nil host logs
29
- let legacyData = Data(dataString: dataString, options: .legacy)
30
- XCTAssertNotNil(legacyData, "Data should not be nil if valid base64 string")
31
- let legacyImage = UIImage(data: legacyData!)
32
- XCTAssertNotNil(legacyImage, "Should be valid image")
33
-
34
- XCTAssertEqual(data, legacyData)
35
- }
36
-
37
- func testValidDataURLWithoutBase64() {
38
- let dataString = "data:image/png,\(red5x5)"
39
- // Since ;base64 is missing still prints nil host warnings.
40
- // If we can figure out how to turn red5x5 into Data properly
41
- // like Data(contentsOf:) does then we can avoid the warning.
42
- let data = Data(dataString: dataString)
43
- XCTAssertNotNil(data, "Data should not be nil since format is valid data URL")
44
-
45
- let image = UIImage(data: data!)
46
- XCTAssertNotNil(image, "Should be valid image. Since missing ';base64' the data is valid just not base64 encoded")
47
- }
48
-
49
- func testInvalidDataURLWithBadBase64() {
50
- let dataString = "data:image/png;base64,INVALIDBASE64"
51
-
52
- let data = Data(dataString: dataString)
53
- let legacyData = Data(dataString: dataString, options: .legacy)
54
- XCTAssertNil(data, "Data should be nil because 'INVALIDBASE64' is not valid base64 string.")
55
- XCTAssertNil(legacyData, "Data should be nil because 'INVALIDBASE64' is not valid base64 string.")
56
- }
57
-
58
- func testInvalidDataURL() {
59
- let dataString = "ImageAssetName"
60
-
61
- let data = Data(dataString: dataString)
62
- XCTAssertNil(data, "Data should be nil as valid Data URL starts with 'data:'")
63
- }
64
- }
@@ -1,45 +0,0 @@
1
- //
2
- // ParsingTests.swift
3
- // Lottie
4
- //
5
- // Created by Marcelo Fabri on 5/5/22.
6
- //
7
-
8
- import Difference
9
- import Foundation
10
- import Lottie
11
- import XCTest
12
-
13
- // MARK: - ParsingTests
14
-
15
- final class ParsingTests: XCTestCase {
16
-
17
- func testParsingIsTheSameForBothImplementations() throws {
18
- for url in Samples.sampleAnimationURLs {
19
- guard url.pathExtension == "json" else { continue }
20
-
21
- do {
22
- let data = try Data(contentsOf: url)
23
- let codableAnimation = try LottieAnimation.from(data: data, strategy: .legacyCodable)
24
- let dictAnimation = try LottieAnimation.from(data: data, strategy: .dictionaryBased)
25
-
26
- XCTAssertNoDiff(codableAnimation, dictAnimation)
27
- } catch {
28
- XCTFail("Error for \(url.lastPathComponent): \(error)")
29
- }
30
- }
31
- }
32
- }
33
-
34
- func XCTAssertNoDiff<T>(
35
- _ expected: @autoclosure () throws -> T,
36
- _ received: @autoclosure () throws -> T,
37
- file: StaticString = #filePath,
38
- line: UInt = #line) rethrows
39
- {
40
- let expected = try expected()
41
- let received = try received()
42
- let diff = diff(expected, received)
43
- let isEqual = diff.isEmpty || diff.allSatisfy(\.isEmpty)
44
- XCTAssertTrue(isEqual, "Found difference for \n" + diff.joined(separator: ", "), file: file, line: line)
45
- }