mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2024-12-29 03:19:44 +00:00
Add simple tests for dialogues
This commit is contained in:
parent
0e1678b3b8
commit
0233640124
@ -1 +0,0 @@
|
||||
# It is an empty file that overrides builtin.omwscripts and disables builtin scripts
|
34
scripts/data/morrowind_tests/global.lua
Normal file
34
scripts/data/morrowind_tests/global.lua
Normal file
@ -0,0 +1,34 @@
|
||||
local testing = require('testing_util')
|
||||
local util = require('openmw.util')
|
||||
local world = require('openmw.world')
|
||||
local core = require('openmw.core')
|
||||
local types = require('openmw.types')
|
||||
|
||||
if not core.contentFiles.has('Morrowind.esm') then
|
||||
error('This test requires Morrowind.esm')
|
||||
end
|
||||
|
||||
function makeTests(modules)
|
||||
local tests = {}
|
||||
|
||||
for _, moduleName in ipairs(modules) do
|
||||
local module = require(moduleName)
|
||||
for _, v in ipairs(module) do
|
||||
table.insert(tests, {string.format('[%s] %s', moduleName, v[1]), v[2]})
|
||||
end
|
||||
end
|
||||
|
||||
return tests
|
||||
end
|
||||
|
||||
local testModules = {
|
||||
'global_issues',
|
||||
'global_dialogues',
|
||||
}
|
||||
|
||||
return {
|
||||
engineHandlers = {
|
||||
onUpdate = testing.testRunner(makeTests(testModules)),
|
||||
},
|
||||
eventHandlers = testing.eventHandlers,
|
||||
}
|
47
scripts/data/morrowind_tests/global_dialogues.lua
Normal file
47
scripts/data/morrowind_tests/global_dialogues.lua
Normal file
@ -0,0 +1,47 @@
|
||||
local testing = require('testing_util')
|
||||
local core = require('openmw.core')
|
||||
|
||||
function iterateOverRecords(records)
|
||||
local firstRecordId = nil
|
||||
local lastRecordId = nil
|
||||
local count = 0
|
||||
for _, v in ipairs(records) do
|
||||
firstRecordId = firstRecordId or v.id
|
||||
lastRecordId = v.id
|
||||
count = count + 1
|
||||
end
|
||||
return firstRecordId, lastRecordId, count
|
||||
end
|
||||
|
||||
return {
|
||||
{'Should support iteration over journal dialogues', function()
|
||||
local firstRecordId, lastRecordId, count = iterateOverRecords(core.dialogue.journal.records)
|
||||
testing.expectEqual(firstRecordId, '11111 test journal')
|
||||
testing.expectEqual(lastRecordId, 'va_vamprich')
|
||||
testing.expectEqual(count, 632)
|
||||
end},
|
||||
{'Should support iteration over topic dialogues', function()
|
||||
local firstRecordId, lastRecordId, count = iterateOverRecords(core.dialogue.topic.records)
|
||||
testing.expectEqual(firstRecordId, '1000-drake pledge')
|
||||
testing.expectEqual(lastRecordId, 'zenithar')
|
||||
testing.expectEqual(count, 1698)
|
||||
end},
|
||||
{'Should support iteration over greeting dialogues', function()
|
||||
local firstRecordId, lastRecordId, count = iterateOverRecords(core.dialogue.greeting.records)
|
||||
testing.expectEqual(firstRecordId, 'greeting 0')
|
||||
testing.expectEqual(lastRecordId, 'greeting 9')
|
||||
testing.expectEqual(count, 10)
|
||||
end},
|
||||
{'Should support iteration over persuasion dialogues', function()
|
||||
local firstRecordId, lastRecordId, count = iterateOverRecords(core.dialogue.persuasion.records)
|
||||
testing.expectEqual(firstRecordId, 'admire fail')
|
||||
testing.expectEqual(lastRecordId, 'taunt success')
|
||||
testing.expectEqual(count, 10)
|
||||
end},
|
||||
{'Should support iteration over voice dialogues', function()
|
||||
local firstRecordId, lastRecordId, count = iterateOverRecords(core.dialogue.voice.records)
|
||||
testing.expectEqual(firstRecordId, 'alarm')
|
||||
testing.expectEqual(lastRecordId, 'thief')
|
||||
testing.expectEqual(count, 8)
|
||||
end},
|
||||
}
|
@ -4,11 +4,7 @@ local world = require('openmw.world')
|
||||
local core = require('openmw.core')
|
||||
local types = require('openmw.types')
|
||||
|
||||
if not core.contentFiles.has('Morrowind.esm') then
|
||||
error('This test requires Morrowind.esm')
|
||||
end
|
||||
|
||||
local tests = {
|
||||
return {
|
||||
{'Player should be able to walk up stairs in Ebonheart docks (#4247)', function()
|
||||
world.players[1]:teleport('', util.vector3(19867, -102180, -79), util.transform.rotateZ(math.rad(91)))
|
||||
coroutine.yield()
|
||||
@ -42,10 +38,3 @@ local tests = {
|
||||
testing.expectThat(types.Container.inventory(barrel):find('ring_keley'), isFargothRing)
|
||||
end},
|
||||
}
|
||||
|
||||
return {
|
||||
engineHandlers = {
|
||||
onUpdate = testing.testRunner(tests),
|
||||
},
|
||||
eventHandlers = testing.eventHandlers,
|
||||
}
|
@ -1,2 +1,2 @@
|
||||
GLOBAL: test.lua
|
||||
GLOBAL: global.lua
|
||||
PLAYER: player.lua
|
@ -7,5 +7,5 @@ data-local=test_workdir
|
||||
data=../integration_tests/testing_util
|
||||
data=.
|
||||
content=Morrowind.esm
|
||||
content=test.omwscripts
|
||||
content=morrowind_tests.omwscripts
|
||||
fallback-archive=Morrowind.bsa
|
||||
|
@ -78,7 +78,7 @@ testing.registerLocalTest('Guard in Imperial Prison Ship should find path (#7241
|
||||
|
||||
return {
|
||||
engineHandlers = {
|
||||
onUpdate = testing.updateLocal,
|
||||
onFrame = testing.updateLocal,
|
||||
},
|
||||
eventHandlers = testing.eventHandlers
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user