78 lines
2.8 KiB
GDScript
78 lines
2.8 KiB
GDScript
extends SceneTree
|
|
|
|
const Controller = preload("res://p10_0/runtime_controller.gd")
|
|
|
|
const VIEWPORT := Vector2i(844, 390)
|
|
const TOUCH_EMULATION_SETTING := "input_devices/pointing/emulate_touch_from_mouse"
|
|
|
|
var failures: Array[String] = []
|
|
var experience
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
|
|
func run_test() -> void:
|
|
root.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS
|
|
root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_EXPAND
|
|
root.content_scale_size = VIEWPORT
|
|
root.size = VIEWPORT
|
|
experience = Controller.new()
|
|
experience.persistence_enabled = false
|
|
experience.size = Vector2(VIEWPORT)
|
|
root.add_child(experience)
|
|
await settle_frames(8)
|
|
await click("P100Difficulty_wayfinder")
|
|
expect(experience.selected_difficulty == "wayfinder", "MouseButton selects difficulty")
|
|
await click("P100NewExpeditionButton")
|
|
expect(experience.screen == "opening", "MouseButton opens the Recruit draft")
|
|
expect(experience.market.state.run_creation_draft.opening_offers.size() == 4, "MouseButton creates four offers")
|
|
var ids: Array[String] = []
|
|
for offer in experience.market.state.run_creation_draft.opening_offers:
|
|
ids.append(String(offer.source_offer_id))
|
|
await click("P100OpeningTarget_%s" % ids[0])
|
|
await click("P100OpeningTarget_%s" % ids[1])
|
|
expect(experience.opening_selection == [ids[0], ids[1]], "MouseButton selects each Recruit exactly once")
|
|
await click("P100CommitRunButton")
|
|
expect(experience.screen == "market", "MouseButton forms the Company")
|
|
var touch_emulation := bool(ProjectSettings.get_setting(TOUCH_EMULATION_SETTING, true))
|
|
var touch_count: int = experience.input_touch_count
|
|
if not touch_emulation:
|
|
expect(touch_count == 0, "direct MouseButton does not enter controller touch ownership")
|
|
experience.queue_free()
|
|
await settle_frames(45)
|
|
if failures.is_empty():
|
|
print("ABG_P10_0_WEB_MOUSE_ACTIVATION_OK difficulty=wayfinder opening=4 selected=2 market=true touch=%d emulation=%s" % [touch_count, str(touch_emulation).to_lower()])
|
|
quit(0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func click(node_name: String) -> void:
|
|
var control := experience.find_child(node_name, true, false) as Control
|
|
expect(control != null, "%s exists before MouseButton" % node_name)
|
|
if control == null:
|
|
return
|
|
var point := root.get_final_transform() * control.get_global_rect().get_center()
|
|
for pressed in [true, false]:
|
|
var event := InputEventMouseButton.new()
|
|
event.button_index = MOUSE_BUTTON_LEFT
|
|
event.position = point
|
|
event.pressed = pressed
|
|
Input.parse_input_event(event)
|
|
await process_frame
|
|
await settle_frames(4)
|
|
|
|
|
|
func settle_frames(count: int) -> void:
|
|
for _index in count:
|
|
await process_frame
|
|
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append("P10.0R1 Web mouse activation: %s" % message)
|