forked from beyond-all-reason/Beyond-All-Reason
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cmd_stop_selfd.lua
More file actions
47 lines (38 loc) · 1.48 KB
/
Copy pathtest_cmd_stop_selfd.lua
File metadata and controls
47 lines (38 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function skip()
return Spring.GetGameFrame() <= 0
end
function setup()
Test.clearMap()
-- Enable UnitCommand callin for tests
Test.expectCallin("UnitCommand")
end
function cleanup()
Test.clearMap()
end
function test()
widget = widgetHandler:FindWidget("Stop means Stop")
assert(widget)
local myTeamID = Spring.GetMyTeamID()
unitID = SyncedRun(function(locals)
local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2
local y = Spring.GetGroundHeight(x, z)
return Spring.CreateUnit("armpw", x, y, z, 0, locals.myTeamID)
end)
-- issue selfd and then issue stop
Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0)
Test.waitUntilCallinArgs("UnitCommand", { nil, nil, nil, CMD.SELFD, nil, nil, nil })
assert(Spring.GetUnitSelfDTime(unitID) > 0)
Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0)
Test.waitUntilCallinArgs("UnitCommand", { nil, nil, nil, CMD.SELFD, nil, nil, nil })
assert(Spring.GetUnitSelfDTime(unitID) == 0)
assert(Spring.GetUnitCommandCount(unitID) == 0)
-- issue {move, selfd}, then issue stop
Spring.GiveOrderToUnit(unitID, CMD.MOVE, { 1, 1, 1 }, 0)
Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, { "shift" })
Test.waitUntilCallinArgs("UnitCommand", { nil, nil, nil, CMD.SELFD, nil, nil, nil })
assert(Spring.GetUnitSelfDTime(unitID) == 0)
Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0)
Test.waitUntilCallinArgs("UnitCommand", { nil, nil, nil, CMD.STOP, nil, nil, nil })
assert(Spring.GetUnitSelfDTime(unitID) == 0)
assert(Spring.GetUnitCommandCount(unitID) == 0)
end