feat: complete mobile UI implementation
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# chat_mobile_ui_test —— 横屏聊天页与私聊输入的移动布局自检。
|
||||
extends SceneTree
|
||||
|
||||
const ChatUI = preload("res://ui/chat_ui.gd")
|
||||
|
||||
class FakeClient extends Node:
|
||||
var sent := []
|
||||
func say(channel: int, text: String) -> bool:
|
||||
sent.append(["say", channel, text]); return true
|
||||
func whisper(name: String, text: String) -> bool:
|
||||
sent.append(["whisper", name, text]); return true
|
||||
|
||||
var _fail := 0
|
||||
func _ck(c: bool, m: String) -> void:
|
||||
if not c:
|
||||
_fail += 1
|
||||
printerr("FAIL: " + m)
|
||||
|
||||
func _init() -> void:
|
||||
_run()
|
||||
if _fail == 0:
|
||||
print("PASS: chat_mobile_ui_test (landscape chat + whisper input)")
|
||||
quit(0)
|
||||
else:
|
||||
printerr("%d check(s) failed" % _fail)
|
||||
quit(1)
|
||||
|
||||
func _run() -> void:
|
||||
var client := FakeClient.new()
|
||||
get_root().add_child(client)
|
||||
var chat := ChatUI.new()
|
||||
get_root().add_child(chat)
|
||||
chat.setup(client, get_root())
|
||||
chat.set_mobile_mode(true)
|
||||
_ck(chat._root.size == Vector2(760, 340), "mobile chat uses landscape page size")
|
||||
_ck(chat._log[0].size == Vector2(732, 190), "mobile chat log has touch-friendly content area")
|
||||
_ck(chat._input.size == Vector2(732, 38), "mobile chat input is keyboard-friendly")
|
||||
_ck(not chat.is_log_visible(), "mobile chat is hidden until explicitly opened")
|
||||
chat.toggle_log()
|
||||
_ck(chat.is_log_visible(), "chat opens from menu")
|
||||
chat._on_submit("/s hello")
|
||||
_ck(client.sent == [["say", 6, "hello"]], "chat channel prefix remains server-compatible")
|
||||
chat.start_whisper("Bob")
|
||||
_ck(chat.is_whisper_open(), "whisper dialog opens")
|
||||
_ck(chat._whisper_dialog.size == Vector2(480, 260), "mobile whisper uses landscape touch layout")
|
||||
chat._on_whisper_submit("hi")
|
||||
_ck(client.sent.size() == 2 and client.sent[1] == ["whisper", "Bob", "hi"],
|
||||
"mobile whisper sends target and message")
|
||||
chat.close()
|
||||
chat.queue_free()
|
||||
client.queue_free()
|
||||
Reference in New Issue
Block a user