Skip to content

Commit 5525707

Browse files
committed
Cleaned up callback tests
Fixes #
1 parent aea267c commit 5525707

File tree

6 files changed

+57
-46
lines changed

6 files changed

+57
-46
lines changed

.github/workflows/ci-workflow.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ jobs:
1515
env:
1616
DEFOLD_USER: [email protected]
1717
DEFOLD_AUTH: foobar
18-
DEFOLD_BOOSTRAP_COLLECTION: /test/test.collectionc
1918
run: ./.test/run.sh

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ build
99
builtins
1010
.internal
1111
luacov.report.out
12+
/.editor_settings
13+
manifest.private.der
14+
manifest.public.der

.test/run.sh

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ else
55
PLATFORM="$1"
66
fi
77

8-
98
echo "${PLATFORM}"
109

1110
# {"version": "1.2.89", "sha1": "5ca3dd134cc960c35ecefe12f6dc81a48f212d40"}
@@ -16,26 +15,28 @@ echo "Using Defold dmengine_headless version ${SHA1}"
1615
# Create dmengine_headless and bob.jar URLs
1716
DMENGINE_URL="http://d.defold.com/archive/${SHA1}/engine/${PLATFORM}/dmengine_headless"
1817
BOB_URL="http://d.defold.com/archive/${SHA1}/bob/bob.jar"
18+
DMENGINE_FILE=dmengine_headless_${SHA1}
19+
BOB_FILE=bob_${SHA1}.jar
1920

2021
# Download dmengine_headless
21-
echo "Downloading ${DMENGINE_URL}"
22-
curl -L -o dmengine_headless ${DMENGINE_URL}
23-
chmod +x dmengine_headless
22+
if ! [ -f ${DMENGINE_FILE} ]; then
23+
echo "Downloading ${DMENGINE_URL} to ${DMENGINE_FILE}"
24+
curl -L -o ${DMENGINE_FILE} ${DMENGINE_URL}
25+
chmod +x ${DMENGINE_FILE}
26+
fi
2427

2528
# Download bob.jar
26-
echo "Downloading ${BOB_URL}"
27-
curl -L -o bob.jar ${BOB_URL}
29+
if ! [ -f ${BOB_FILE} ]; then
30+
echo "Downloading ${BOB_URL} to ${BOB_FILE}"
31+
curl -L -o ${BOB_FILE} ${BOB_URL}
32+
fi
2833

2934
# Fetch libraries
30-
echo "Running bob.jar - resolving dependencies"
31-
java -jar bob.jar --auth "foobar" --email "[email protected]" resolve
35+
echo "Running ${BOB_FILE} - resolving dependencies"
36+
java -jar ${BOB_FILE} --auth "foobar" --email "[email protected]" resolve
3237

33-
echo "Running bob.jar - building"
34-
java -jar bob.jar --debug build --keep-unused
38+
echo "Running ${BOB_FILE} - building"
39+
java -jar ${BOB_FILE} --debug build --settings=test.settings
3540

36-
echo "Starting dmengine_headless"
37-
if [ -n "${DEFOLD_BOOSTRAP_COLLECTION}" ]; then
38-
./dmengine_headless --config=bootstrap.main_collection=${DEFOLD_BOOSTRAP_COLLECTION}
39-
else
40-
./dmengine_headless
41-
fi
41+
echo "Starting ${DMENGINE_FILE}"
42+
./${DMENGINE_FILE}

test.settings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bootstrap]
2+
main_collection = /test/test.collectionc

test/msg.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,17 @@ function M.last(url)
6464
return messages[#messages]
6565
end
6666

67+
function M.filter(url, fn)
68+
local t = {}
69+
local messages = M.messages(url)
70+
for i=1,#messages do
71+
local message = messages[i]
72+
if fn(message) then
73+
t[#t + 1] = message
74+
end
75+
end
76+
return t
77+
end
78+
6779

6880
return M

test/test_monarch.lua

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -418,43 +418,37 @@ return function()
418418

419419
monarch.show(SCREEN1)
420420
assert(wait_until_not_busy())
421-
assert(mock_msg.messages(URL1)[1].message_id == monarch.SCREEN_TRANSITION_IN_STARTED)
422-
assert(mock_msg.messages(URL1)[1].message.screen == SCREEN1)
423-
assert(mock_msg.messages(URL2)[1].message_id == monarch.SCREEN_TRANSITION_IN_STARTED)
424-
assert(mock_msg.messages(URL2)[1].message.screen == SCREEN1)
425-
assert(mock_msg.messages(URL1)[2].message_id == monarch.SCREEN_TRANSITION_IN_FINISHED)
426-
assert(mock_msg.messages(URL1)[2].message.screen == SCREEN1)
427-
assert(mock_msg.messages(URL2)[2].message_id == monarch.SCREEN_TRANSITION_IN_FINISHED)
428-
assert(mock_msg.messages(URL2)[2].message.screen == SCREEN1)
429421

430422
monarch.remove_listener(URL2)
431423
monarch.show(SCREEN2)
432424
assert(wait_until_not_busy())
433425

434-
assert(#mock_msg.messages(URL1) == 6)
435-
assert(#mock_msg.messages(URL2) == 2)
436-
assert(mock_msg.messages(URL1)[3].message_id == monarch.SCREEN_TRANSITION_IN_STARTED)
437-
assert(mock_msg.messages(URL1)[3].message.screen == SCREEN2)
438-
assert(mock_msg.messages(URL1)[4].message_id == monarch.SCREEN_TRANSITION_OUT_STARTED)
439-
assert(mock_msg.messages(URL1)[4].message.screen == SCREEN1)
440-
assert(mock_msg.messages(URL1)[5].message_id == monarch.SCREEN_TRANSITION_IN_FINISHED)
441-
assert(mock_msg.messages(URL1)[5].message.screen == SCREEN2)
442-
assert(mock_msg.messages(URL1)[6].message_id == monarch.SCREEN_TRANSITION_OUT_FINISHED)
443-
assert(mock_msg.messages(URL1)[6].message.screen == SCREEN1)
444-
445426
monarch.back()
446427
assert(wait_until_not_busy())
447428

448-
assert(#mock_msg.messages(URL1) == 10)
449-
assert(#mock_msg.messages(URL2) == 2)
450-
assert(mock_msg.messages(URL1)[7].message_id == monarch.SCREEN_TRANSITION_IN_STARTED)
451-
assert(mock_msg.messages(URL1)[7].message.screen == SCREEN1)
452-
assert(mock_msg.messages(URL1)[8].message_id == monarch.SCREEN_TRANSITION_OUT_STARTED)
453-
assert(mock_msg.messages(URL1)[8].message.screen == SCREEN2)
454-
assert(mock_msg.messages(URL1)[9].message_id == monarch.SCREEN_TRANSITION_IN_FINISHED)
455-
assert(mock_msg.messages(URL1)[9].message.screen == SCREEN1)
456-
assert(mock_msg.messages(URL1)[10].message_id == monarch.SCREEN_TRANSITION_OUT_FINISHED)
457-
assert(mock_msg.messages(URL1)[10].message.screen == SCREEN2)
429+
local messages = mock_msg.filter(URL1, function(m)
430+
return m.message.screen == SCREEN1
431+
end)
432+
assert(messages[1].message_id == monarch.SCREEN_TRANSITION_IN_STARTED)
433+
assert(messages[2].message_id == monarch.SCREEN_TRANSITION_IN_FINISHED)
434+
assert(messages[3].message_id == monarch.SCREEN_TRANSITION_OUT_STARTED)
435+
assert(messages[4].message_id == monarch.SCREEN_TRANSITION_OUT_FINISHED)
436+
assert(messages[5].message_id == monarch.SCREEN_TRANSITION_IN_STARTED)
437+
assert(messages[6].message_id == monarch.SCREEN_TRANSITION_IN_FINISHED)
438+
439+
messages = mock_msg.filter(URL2, function(m)
440+
return m.message.screen == SCREEN1
441+
end)
442+
assert(messages[1].message_id == monarch.SCREEN_TRANSITION_IN_STARTED)
443+
assert(messages[2].message_id == monarch.SCREEN_TRANSITION_IN_FINISHED)
444+
445+
messages = mock_msg.filter(URL1, function(m)
446+
return m.message.screen == SCREEN2
447+
end)
448+
assert(messages[1].message_id == monarch.SCREEN_TRANSITION_IN_STARTED)
449+
assert(messages[2].message_id == monarch.SCREEN_TRANSITION_IN_FINISHED)
450+
assert(messages[3].message_id == monarch.SCREEN_TRANSITION_OUT_STARTED)
451+
assert(messages[4].message_id == monarch.SCREEN_TRANSITION_OUT_FINISHED)
458452
end)
459453

460454
it("should be able to show a screen even while it is preloading", function()

0 commit comments

Comments
 (0)