Add tests for DesktopAssetManager cache and asset events#2812
Add tests for DesktopAssetManager cache and asset events#2812Dingyi189-eng wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a new test class, DesktopAssetManagerCacheTest, to verify caching and AssetEventListener behavior in DesktopAssetManager. A critical issue was identified in the cachedLoadFiresRequestedButNotSecondLoadedEvent test, where Assert.assertNotSame(first, second) is used incorrectly. Since Texture is a shared asset and not cloned upon cache retrieval, both instances should be identical, and the assertion should be updated to Assert.assertSame to prevent the test from failing.
| Assert.assertEquals(2, listener.requestCount()); | ||
| Assert.assertEquals(1, listener.loadedCount()); | ||
| Assert.assertNotNull(assetManager.getFromCache(textureKey)); | ||
| Assert.assertNotSame(first, second); |
There was a problem hiding this comment.
Since Texture is not a CloneableSmartAsset, it is a shared asset and is not cloned upon cache retrieval. Therefore, the first and second loaded textures should be the exact same instance. Using Assert.assertNotSame(first, second) will cause the test to fail. It should be changed to Assert.assertSame(first, second).
| Assert.assertNotSame(first, second); | |
| Assert.assertSame(first, second); |
References
- Issues found in test code should be reported with a reduced priority, at most medium.
Adds unit tests for DesktopAssetManager caching and AssetEventListener callbacks.
Run: ./gradlew :jme3-core:test --tests "com.jme3.asset.DesktopAssetManagerCacheTest"