mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-03-21 19:23:41 +00:00
* Unit Test rework & Master/Ticker update * Fixes and working unit testing * Fixes * Test fixes and FA update * Fixed runtimes * Radio subsystem * move that glob wherever later * ident * CIBUILDING compile option * Fixed runtimes * Some changes to the workflow * CI Split * More split * Pathing * Linters and Annotators * ci dir fix * Missing undef fixed * Enable grep checks * More test conversions * More split * Correct file * Removes unneeded inputs * oop * More dependency changes * More conversions * Conversion fixes * Fixes * Some assert fixes * Corrects start gate * Converted some README.dms to README.mds * Removes duplicate proc * Removes unused defines * Example configs * fix dll access viol by double calling * Post-rebase fixes * Cleans up names global list * Undef restart counter * More code/game/ cleanup * Statpanel update * Skybox * add * Fix ticker * Roundend fix * Persistence dependency update * Reordering * Reordering * Reordering * Initstage fix * . * . * Reorder * Reorder * Circle * Mobs * Air * Test fix * CI Script Fix * Configs * More ticker stuff * This is now in 'reboot world' * Restart world announcements * no glob in PreInit * to define * Update * Removed old include * Make this file normal again * moved * test * shared unit testing objects * Updates batched_spritesheets and universal_icon * . * job data debug * rm that * init order * show us * . * i wonder * . * . * urg * do we not have a job ID? * . * rm sleep for now * updated rust-g linux binaries * binaries update 2 * binaries update 3 * testing something * change that * test something * . * . * . * locavar * test * move that * . * debug * don't run this test * strack trace it * cleaner * . * . * cras again * also comment this out * return to official rust g * Update robot_icons.dm * monitor the generation * . --------- Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
64 lines
2.9 KiB
Plaintext
64 lines
2.9 KiB
Plaintext
/datum/asset/spritesheet_batched/test
|
|
name = "test"
|
|
load_immediately = TRUE
|
|
force_cache = TRUE
|
|
// Don't let the asset subsystem load this. This is how we trick it.
|
|
_abstract = /datum/asset/spritesheet_batched/test
|
|
var/static/list/items = list(/obj/item/binoculars, /obj/item/camera, /obj/item/clothing/under/color/blue, /obj/item/clothing/under/color/black)
|
|
|
|
/datum/asset/spritesheet_batched/test/create_spritesheets()
|
|
for(var/atom/item as anything in items)
|
|
if (!ispath(item, /atom))
|
|
return FALSE
|
|
var/imgid = replacetext(replacetext("[item]", "/obj/item/", ""), "/", "-")
|
|
insert_icon(imgid, get_display_icon_for(item))
|
|
// Get some coverage on each operation.
|
|
var/datum/universal_icon/I = uni_icon('icons/effects/effects.dmi', "nothing")
|
|
I.blend_icon(uni_icon('icons/effects/effects.dmi', "sparks"), ICON_OVERLAY)
|
|
I.blend_color("#ff0000", ICON_MULTIPLY)
|
|
I.scale(64, 64)
|
|
I.crop(1, 1, 128, 64) // we'll test for the scale later.
|
|
insert_icon("test", I)
|
|
|
|
/datum/asset/spritesheet_batched/test/unregister()
|
|
SSassets.transport.unregister_asset("spritesheet_[name].css")
|
|
if(length(sizes))
|
|
for(var/size_id in sizes)
|
|
SSassets.transport.unregister_asset("[name]_[size_id].png")
|
|
|
|
/datum/unit_test/test_asset_smart_cache/Run()
|
|
fdel("[ASSET_CROSS_ROUND_SMART_CACHE_DIRECTORY]/spritesheet_cache.test.json")
|
|
fdel("data/spritesheets/spritesheet_test.css")
|
|
var/datum/asset/spritesheet_batched/test/sheet = new()
|
|
TEST_ASSERT(sheet.fully_generated, "Spritesheet not generated!")
|
|
// Cache should be invalid initially.
|
|
TEST_ASSERT(sheet.cache_result, "Spritesheet smart cache was VALID when it should be INVALID!")
|
|
for(var/item in sheet.items)
|
|
var/imgid = replacetext(replacetext("[item]", "/obj/item/", ""), "/", "-")
|
|
// All items should be in sprites list.
|
|
TEST_ASSERT(imgid in sheet.sprites, "Item [item] not present in spritesheet result!")
|
|
TEST_ASSERT("test" in sheet.sprites, "Item test not present in spritesheet result!")
|
|
TEST_ASSERT("128x64" in sheet.sizes, "Test icon was not output as 128x64!")
|
|
// cache wrote properly
|
|
TEST_ASSERT(fexists("[ASSET_CROSS_ROUND_SMART_CACHE_DIRECTORY]/spritesheet_cache.test.json"), "Smart cache entry did not write!")
|
|
// Clear it out and get ready to do it again, this time loading from cache
|
|
sheet.unregister()
|
|
sheet.entries = list()
|
|
sheet.sprites = list()
|
|
sheet.sizes = list()
|
|
sheet.job_id = null
|
|
sheet.cache_result = null
|
|
sheet.cache_data = null
|
|
sheet.cache_job_id = null
|
|
sheet.fully_generated = FALSE
|
|
|
|
sheet.register()
|
|
TEST_ASSERT(sheet.fully_generated, "Spritesheet did not load from smart cache properly!")
|
|
// Check for CACHE_VALID
|
|
TEST_ASSERT(!sheet.cache_result, "Spritesheet did not load from smart cache, it was invalid despite having the same input data!")
|
|
// Cleanup files.
|
|
fdel("[ASSET_CROSS_ROUND_SMART_CACHE_DIRECTORY]/spritesheet_cache.test.json")
|
|
fdel("data/spritesheets/spritesheet_test.css")
|
|
for(var/size in sheet.sizes)
|
|
fdel("data/spritesheets/test_[size].png")
|