extends RefCounted ## The phone tests: every game/tests/mobile/*_test.gd (one file per task), in name order, each ## with the runner's check(). A test file extends RefCounted and has `func run(t) -> void` (it ## may await); it forces a phone or desktop with MobilePort.forced = 1 or 0, sends fingers with ## mobile/touch.gd, and before it returns sets MobilePort.forced back to -1 and frees what it ## added (checked here). Between files this puts the root window back as it was (its size and ## content_scale_factor, which a phone's GameSettings.apply changes), along with the desktop ## preview's density and insets (MobilePort.preview_dpi, preview_insets) and the pause. ## Run just these: -- --suite=test_mobile const DIR := "res://game/tests/mobile/" func run(t: GameTestRunner) -> void: var files: Array[String] = [] for f in DirAccess.get_files_at(DIR): if f.ends_with("_test.gd"): files.append(f) files.sort() t.check(not files.is_empty(), "%s has tests" % DIR) var suite := t.current var size := t.root.size var factor := t.root.content_scale_factor for f in files: var name := f.get_basename() print("-- ", name) t.current = "%s/%s" % [suite, name] var test: Object = (load(DIR + f) as GDScript).new() await test.call("run", t) t.check(MobilePort.forced == -1, "it set MobilePort.forced back to -1") MobilePort.forced = -1 MobilePort.preview_dpi = 0.0 MobilePort.preview_insets = [] t.root.size = size t.root.content_scale_factor = factor t.paused = false await t.process_frame t.current = suite