From 50b6e20f91530eaa6b3aabb0c20979b3503f68d8 Mon Sep 17 00:00:00 2001 From: Ivan Murzak Date: Mon, 17 Mar 2025 09:00:00 -0700 Subject: [PATCH 1/5] Fixed compilation error in player build --- .../Tests/Base/Utils/TestUtils.LoadFail.cs | 6 +++++- Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs index 8076c04..57cff7c 100644 --- a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs +++ b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs @@ -28,8 +28,12 @@ public static IEnumerator LoadFail(string url, FutureLoadingFrom? expectedLoadin futureListener.Assert_Events_Contains(expectedLoadingFrom.Value.ToEventName()); var task1 = future.AsTask(); + +// TODO: To find a way to use it a player build +#if UNITY_EDITOR if (expectedLoadingFrom.HasValue && expectedLoadingFrom.Value == FutureLoadingFrom.Source) // exception should be thrown only if ONLY loading from Source - LogAssert.Expect(LogType.Error, $"[ImageLoader] Future[id={future.Id}] Timeout ({timeout}): {url}"); + LogAssert.Expect(LogType.Error, $"[ImageLoader] Future[id={future.Id}] Timeout ({timeout}): {url}"); // compilation error in player build +#endif yield return TestUtils.WaitWhile(() => future.IsInProgress, TimeSpan.FromSeconds(10)); var task2 = future.AsTask(); diff --git a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs index 7ffd901..bbf6578 100644 --- a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs +++ b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs @@ -32,14 +32,21 @@ public static IEnumerator ClearEverything(string message) { if (message != null) Debug.Log(message.PadRight(50, '-')); - LogAssert.ignoreFailingMessages = true; +// TODO: To find a way to use it a player build +#if UNITY_EDITOR + LogAssert.ignoreFailingMessages = true; // compilation error in player build +#endif UniTaskScheduler.UnobservedExceptionWriteLogType = LogType.Exception; ImageLoader.ClearSpriteRef(); ImageLoader.ClearTextureRef(); yield return ImageLoader.ClearCacheAll().TimeoutCoroutine(TimeSpan.FromSeconds(10)); WaitForGCFast(); - LogAssert.ignoreFailingMessages = false; + +// TODO: To find a way to use it a player build +#if UNITY_EDITOR + LogAssert.ignoreFailingMessages = false; // compilation error in player build +#endif } public static void WaitForGCFast() { From 485e330176003b113ff4fa0d7f43c8df80fff541 Mon Sep 17 00:00:00 2001 From: Ivan Murzak Date: Mon, 17 Mar 2025 09:00:51 -0700 Subject: [PATCH 2/5] Update package.json --- Assets/_PackageRoot/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/_PackageRoot/package.json b/Assets/_PackageRoot/package.json index dc9ee8a..8c1b3ed 100644 --- a/Assets/_PackageRoot/package.json +++ b/Assets/_PackageRoot/package.json @@ -7,7 +7,7 @@ "url": "https://github.com/IvanMurzak" }, "license": "MIT", - "version": "7.0.0", + "version": "7.0.1", "unity": "2019.4", "description": "Asynchronous image loading from remote or local destination. It has two layers of configurable Memory and Disk cache systems.", "keywords": [ From ce470d1205645d8b575daace6d89327d826f1a64 Mon Sep 17 00:00:00 2001 From: Ivan Murzak Date: Tue, 18 Mar 2025 21:46:32 -0700 Subject: [PATCH 3/5] Refactor test utilities to improve compatibility with player builds --- .../_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs | 5 ++--- Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs | 9 ++++----- Assets/_PackageRoot/Tests/Runtime/TestConcurrency.cs | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs index 57cff7c..3cb5876 100644 --- a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs +++ b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs @@ -3,7 +3,6 @@ using Cysharp.Threading.Tasks; using NUnit.Framework; using UnityEngine; -using UnityEngine.TestTools; namespace Extensions.Unity.ImageLoader.Tests.Utils { @@ -29,10 +28,10 @@ public static IEnumerator LoadFail(string url, FutureLoadingFrom? expectedLoadin var task1 = future.AsTask(); -// TODO: To find a way to use it a player build +// TODO: To find a way to use it in a player build #if UNITY_EDITOR if (expectedLoadingFrom.HasValue && expectedLoadingFrom.Value == FutureLoadingFrom.Source) // exception should be thrown only if ONLY loading from Source - LogAssert.Expect(LogType.Error, $"[ImageLoader] Future[id={future.Id}] Timeout ({timeout}): {url}"); // compilation error in player build + UnityEngine.TestTools.LogAssert.Expect(LogType.Error, $"[ImageLoader] Future[id={future.Id}] Timeout ({timeout}): {url}"); // compilation error in player build #endif yield return TestUtils.WaitWhile(() => future.IsInProgress, TimeSpan.FromSeconds(10)); var task2 = future.AsTask(); diff --git a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs index bbf6578..53a697f 100644 --- a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs +++ b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs @@ -4,7 +4,6 @@ using System.Linq; using Cysharp.Threading.Tasks; using UnityEngine; -using UnityEngine.TestTools; namespace Extensions.Unity.ImageLoader.Tests.Utils { @@ -32,9 +31,9 @@ public static IEnumerator ClearEverything(string message) { if (message != null) Debug.Log(message.PadRight(50, '-')); -// TODO: To find a way to use it a player build +// TODO: To find a way to use it in a player build #if UNITY_EDITOR - LogAssert.ignoreFailingMessages = true; // compilation error in player build + UnityEngine.TestTools.LogAssert.ignoreFailingMessages = true; // compilation error in player build #endif UniTaskScheduler.UnobservedExceptionWriteLogType = LogType.Exception; ImageLoader.ClearSpriteRef(); @@ -43,9 +42,9 @@ public static IEnumerator ClearEverything(string message) WaitForGCFast(); -// TODO: To find a way to use it a player build +// TODO: To find a way to use it in a player build #if UNITY_EDITOR - LogAssert.ignoreFailingMessages = false; // compilation error in player build + UnityEngine.TestTools.LogAssert.ignoreFailingMessages = false; // compilation error in player build #endif } public static void WaitForGCFast() diff --git a/Assets/_PackageRoot/Tests/Runtime/TestConcurrency.cs b/Assets/_PackageRoot/Tests/Runtime/TestConcurrency.cs index 546d16a..283bfe6 100644 --- a/Assets/_PackageRoot/Tests/Runtime/TestConcurrency.cs +++ b/Assets/_PackageRoot/Tests/Runtime/TestConcurrency.cs @@ -3,10 +3,10 @@ using System.Collections; using NUnit.Framework; using Cysharp.Threading.Tasks; -using UnityEngine.TestTools; using UnityEngine; using System.Threading.Tasks; using Extensions.Unity.ImageLoader.Tests.Utils; +using UnityEngine.TestTools; namespace Extensions.Unity.ImageLoader.Tests { From 222eafe0b96829627a7c38b6fe89d72ca4190d0e Mon Sep 17 00:00:00 2001 From: Ivan Murzak Date: Wed, 19 Mar 2025 00:48:47 -0700 Subject: [PATCH 4/5] Fixed compilation errors in tests during compilation player's build --- .../Base/Extensions.Unity.ImageLoader.Tests.asmdef | 10 ++++++---- .../Tests/Base/Utils/TestUtils.LoadFail.cs | 5 ++--- Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs | 8 ++------ .../Extensions.Unity.ImageLoader.Tests.Editor.asmdef | 10 ++++++---- .../Extensions.Unity.ImageLoader.Tests.Runtime.asmdef | 10 ++++++---- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Assets/_PackageRoot/Tests/Base/Extensions.Unity.ImageLoader.Tests.asmdef b/Assets/_PackageRoot/Tests/Base/Extensions.Unity.ImageLoader.Tests.asmdef index dcaeb90..5aaddc4 100644 --- a/Assets/_PackageRoot/Tests/Base/Extensions.Unity.ImageLoader.Tests.asmdef +++ b/Assets/_PackageRoot/Tests/Base/Extensions.Unity.ImageLoader.Tests.asmdef @@ -8,12 +8,14 @@ "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, - "overrideReferences": false, + "overrideReferences": true, "precompiledReferences": [ - "NSubstitute.dll" + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" ], - "autoReferenced": true, - "defineConstraints": [], "versionDefines": [], "noEngineReferences": false } \ No newline at end of file diff --git a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs index 3cb5876..f41fa3d 100644 --- a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs +++ b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs @@ -28,11 +28,10 @@ public static IEnumerator LoadFail(string url, FutureLoadingFrom? expectedLoadin var task1 = future.AsTask(); -// TODO: To find a way to use it in a player build -#if UNITY_EDITOR + if (expectedLoadingFrom.HasValue && expectedLoadingFrom.Value == FutureLoadingFrom.Source) // exception should be thrown only if ONLY loading from Source UnityEngine.TestTools.LogAssert.Expect(LogType.Error, $"[ImageLoader] Future[id={future.Id}] Timeout ({timeout}): {url}"); // compilation error in player build -#endif + yield return TestUtils.WaitWhile(() => future.IsInProgress, TimeSpan.FromSeconds(10)); var task2 = future.AsTask(); diff --git a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs index 53a697f..e6f2c0d 100644 --- a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs +++ b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs @@ -31,10 +31,9 @@ public static IEnumerator ClearEverything(string message) { if (message != null) Debug.Log(message.PadRight(50, '-')); -// TODO: To find a way to use it in a player build -#if UNITY_EDITOR + UnityEngine.TestTools.LogAssert.ignoreFailingMessages = true; // compilation error in player build -#endif + UniTaskScheduler.UnobservedExceptionWriteLogType = LogType.Exception; ImageLoader.ClearSpriteRef(); ImageLoader.ClearTextureRef(); @@ -42,10 +41,7 @@ public static IEnumerator ClearEverything(string message) WaitForGCFast(); -// TODO: To find a way to use it in a player build -#if UNITY_EDITOR UnityEngine.TestTools.LogAssert.ignoreFailingMessages = false; // compilation error in player build -#endif } public static void WaitForGCFast() { diff --git a/Assets/_PackageRoot/Tests/Editor/Extensions.Unity.ImageLoader.Tests.Editor.asmdef b/Assets/_PackageRoot/Tests/Editor/Extensions.Unity.ImageLoader.Tests.Editor.asmdef index 0cb286a..233d018 100644 --- a/Assets/_PackageRoot/Tests/Editor/Extensions.Unity.ImageLoader.Tests.Editor.asmdef +++ b/Assets/_PackageRoot/Tests/Editor/Extensions.Unity.ImageLoader.Tests.Editor.asmdef @@ -12,12 +12,14 @@ ], "excludePlatforms": [], "allowUnsafeCode": false, - "overrideReferences": false, + "overrideReferences": true, "precompiledReferences": [ - "NSubstitute.dll" + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" ], - "autoReferenced": true, - "defineConstraints": [], "versionDefines": [], "noEngineReferences": false } \ No newline at end of file diff --git a/Assets/_PackageRoot/Tests/Runtime/Extensions.Unity.ImageLoader.Tests.Runtime.asmdef b/Assets/_PackageRoot/Tests/Runtime/Extensions.Unity.ImageLoader.Tests.Runtime.asmdef index 91b1c32..2bb0f58 100644 --- a/Assets/_PackageRoot/Tests/Runtime/Extensions.Unity.ImageLoader.Tests.Runtime.asmdef +++ b/Assets/_PackageRoot/Tests/Runtime/Extensions.Unity.ImageLoader.Tests.Runtime.asmdef @@ -9,12 +9,14 @@ "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, - "overrideReferences": false, + "overrideReferences": true, "precompiledReferences": [ - "NSubstitute.dll" + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" ], - "autoReferenced": true, - "defineConstraints": [], "versionDefines": [], "noEngineReferences": false } \ No newline at end of file From 7078a47ddcb9edc9a54b24b717202813a215faae Mon Sep 17 00:00:00 2001 From: Ivan Murzak Date: Wed, 19 Mar 2025 00:51:23 -0700 Subject: [PATCH 5/5] Minor refactoring --- Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs | 4 ++-- Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs index f41fa3d..1bafc99 100644 --- a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs +++ b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.LoadFail.cs @@ -3,6 +3,7 @@ using Cysharp.Threading.Tasks; using NUnit.Framework; using UnityEngine; +using UnityEngine.TestTools; namespace Extensions.Unity.ImageLoader.Tests.Utils { @@ -28,9 +29,8 @@ public static IEnumerator LoadFail(string url, FutureLoadingFrom? expectedLoadin var task1 = future.AsTask(); - if (expectedLoadingFrom.HasValue && expectedLoadingFrom.Value == FutureLoadingFrom.Source) // exception should be thrown only if ONLY loading from Source - UnityEngine.TestTools.LogAssert.Expect(LogType.Error, $"[ImageLoader] Future[id={future.Id}] Timeout ({timeout}): {url}"); // compilation error in player build + LogAssert.Expect(LogType.Error, $"[ImageLoader] Future[id={future.Id}] Timeout ({timeout}): {url}"); // compilation error in player build yield return TestUtils.WaitWhile(() => future.IsInProgress, TimeSpan.FromSeconds(10)); var task2 = future.AsTask(); diff --git a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs index e6f2c0d..503e6be 100644 --- a/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs +++ b/Assets/_PackageRoot/Tests/Base/Utils/TestUtils.cs @@ -4,6 +4,7 @@ using System.Linq; using Cysharp.Threading.Tasks; using UnityEngine; +using UnityEngine.TestTools; namespace Extensions.Unity.ImageLoader.Tests.Utils { @@ -32,7 +33,7 @@ public static IEnumerator ClearEverything(string message) if (message != null) Debug.Log(message.PadRight(50, '-')); - UnityEngine.TestTools.LogAssert.ignoreFailingMessages = true; // compilation error in player build + LogAssert.ignoreFailingMessages = true; // compilation error in player build UniTaskScheduler.UnobservedExceptionWriteLogType = LogType.Exception; ImageLoader.ClearSpriteRef(); @@ -41,7 +42,7 @@ public static IEnumerator ClearEverything(string message) WaitForGCFast(); - UnityEngine.TestTools.LogAssert.ignoreFailingMessages = false; // compilation error in player build + LogAssert.ignoreFailingMessages = false; // compilation error in player build } public static void WaitForGCFast() {