55 lines
2.2 KiB
GDScript
55 lines
2.2 KiB
GDScript
extends SceneTree
|
|
|
|
const PageView = preload("res://presentation/page_view.gd")
|
|
const Tokens = preload("res://foundation/ui_tokens.gd")
|
|
const UIFactory = preload("res://ui/shared/ui_factory.gd")
|
|
|
|
var failures: Array[String] = []
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
|
|
func run_test() -> void:
|
|
root.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS
|
|
# Single target size (owner policy): every screen is authored at 1280x720.
|
|
root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_KEEP
|
|
root.content_scale_size = Vector2i(1280, 720)
|
|
root.size = Vector2i(1280, 720)
|
|
var view := PageView.new()
|
|
root.add_child(view)
|
|
await process_frame
|
|
var compact_data := view.make_unified_mvp_shell(view, "Compact", "隐藏", "隐藏", "隐藏", true)
|
|
await process_frame
|
|
var compact := compact_data.get("root") as Control
|
|
var top := compact_data.get("top") as Panel
|
|
var bottom := compact_data.get("bottom") as Panel
|
|
expect(top.offset_bottom <= 4.0, "compact shell top rail is rule-height")
|
|
expect(bottom.offset_top >= -2.0, "compact shell bottom rail is rule-height")
|
|
expect(top.get_theme_stylebox("panel").bg_color.a <= 0.01, "compact top rail is transparent")
|
|
expect(bottom.get_theme_stylebox("panel").bg_color.a <= 0.01, "compact bottom rail is transparent")
|
|
expect(not bool(compact.find_child("CompactShellTitle", true, false).visible), "compact shell hides duplicate title")
|
|
|
|
var button := UIFactory.command_button("ProbeCommand", "继续", "secondary", "confirm", "flat", "content", Vector2(180, 48))
|
|
view.add_child(button)
|
|
await process_frame
|
|
var normal := button.get_theme_stylebox("normal") as StyleBoxFlat
|
|
expect(normal != null and normal.border_width_left <= Tokens.border_width("hairline"), "secondary command uses a hairline border")
|
|
expect(normal != null and normal.bg_color.a >= 0.8, "secondary command has a visible normal surface")
|
|
button.queue_free()
|
|
view.queue_free()
|
|
await process_frame
|
|
if failures.is_empty():
|
|
print("ABG_M48_UI_LAYER_CLEANUP_OK compact_rules=true command_surfaces=true duplicate_chrome=false")
|
|
quit(0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append("M48 UI Layer Cleanup: %s" % message)
|