chore(client): add gdUnit4 test framework addon
Vendor gdUnit4 for Godot 4 client testing (D-030). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
class_name RPC
|
||||
extends RefCounted
|
||||
|
||||
|
||||
var _data: Dictionary = {}
|
||||
|
||||
|
||||
func _init(obj: Object = null) -> void:
|
||||
if obj != null:
|
||||
if obj.has_method("serialize"):
|
||||
_data = obj.call("serialize")
|
||||
else:
|
||||
_data = inst_to_dict(obj)
|
||||
|
||||
|
||||
func get_data() -> Object:
|
||||
return dict_to_inst(_data)
|
||||
|
||||
|
||||
func serialize() -> String:
|
||||
return JSON.stringify(inst_to_dict(self))
|
||||
|
||||
|
||||
# using untyped version see comments below
|
||||
static func deserialize(json_value: String) -> Object:
|
||||
var json := JSON.new()
|
||||
var err := json.parse(json_value)
|
||||
if err != OK:
|
||||
push_error("Can't deserialize JSON, error at line %d:\n error: %s \n json: '%s'"
|
||||
% [json.get_error_line(), json.get_error_message(), json_value])
|
||||
return null
|
||||
var result: Dictionary = json.get_data()
|
||||
if not typeof(result) == TYPE_DICTIONARY:
|
||||
push_error("Can't deserialize JSON. Expecting dictionary, error at line %d:\n error: %s \n json: '%s'"
|
||||
% [result.error_line, result.error_string, json_value])
|
||||
return null
|
||||
return dict_to_inst(result)
|
||||
@@ -0,0 +1 @@
|
||||
uid://jait5n7vbrfd
|
||||
@@ -0,0 +1,13 @@
|
||||
class_name RPCClientConnect
|
||||
extends RPC
|
||||
|
||||
var _client_id: int
|
||||
|
||||
|
||||
func with_id(id: int) -> RPCClientConnect:
|
||||
_client_id = id
|
||||
return self
|
||||
|
||||
|
||||
func client_id() -> int:
|
||||
return _client_id
|
||||
@@ -0,0 +1 @@
|
||||
uid://cc8jxqn7tvv44
|
||||
@@ -0,0 +1,13 @@
|
||||
class_name RPCClientDisconnect
|
||||
extends RPC
|
||||
|
||||
var _client_id: int
|
||||
|
||||
|
||||
func with_id(id: int) -> RPCClientDisconnect:
|
||||
_client_id = id
|
||||
return self
|
||||
|
||||
|
||||
func client_id() -> int:
|
||||
return _client_id
|
||||
@@ -0,0 +1 @@
|
||||
uid://c67vtfsgam8g
|
||||
@@ -0,0 +1,14 @@
|
||||
class_name RPCGdUnitEvent
|
||||
extends RPC
|
||||
|
||||
|
||||
static func of(p_event: GdUnitEvent) -> RPCGdUnitEvent:
|
||||
return RPCGdUnitEvent.new(p_event)
|
||||
|
||||
|
||||
func event() -> GdUnitEvent:
|
||||
return GdUnitEvent.new().deserialize(_data)
|
||||
|
||||
|
||||
func _to_string() -> String:
|
||||
return "RPCGdUnitEvent: " + str(_data)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dn157jkjh10vw
|
||||
@@ -0,0 +1,18 @@
|
||||
class_name RPCMessage
|
||||
extends RPC
|
||||
|
||||
var _message: String
|
||||
|
||||
|
||||
static func of(msg :String) -> RPCMessage:
|
||||
var rpc := RPCMessage.new()
|
||||
rpc._message = msg
|
||||
return rpc
|
||||
|
||||
|
||||
func message() -> String:
|
||||
return _message
|
||||
|
||||
|
||||
func _to_string() -> String:
|
||||
return "RPCMessage: " + _message
|
||||
@@ -0,0 +1 @@
|
||||
uid://by4gy5xupil2c
|
||||
Reference in New Issue
Block a user