Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drawing-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sweng-group-15
drawing-app
Commits
3fab2647
Commit
3fab2647
authored
5 years ago
by
Moritz Langenstein
Browse files
Options
Downloads
Patches
Plain Diff
(ml5717) Added network->frontend correctness test for path
parent
92130ce7
No related branches found
Branches containing commit
No related tags found
1 merge request
!67
Benchmark testing
Pipeline
#107264
passed
5 years ago
Stage: fetch
Stage: deps
Stage: check
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
__tests__/benchmark.test.js
+153
-13
153 additions, 13 deletions
__tests__/benchmark.test.js
with
153 additions
and
13 deletions
__tests__/benchmark.test.js
+
153
−
13
View file @
3fab2647
...
...
@@ -322,7 +322,7 @@ describe("drawing app mesh", () => {
let
timeout
return
new
Promise
((
resolve
)
=>
{
// Draw the dot
path
// Draw the dot
broadcastListener
.
callback
=
(
channel
,
message
)
=>
{
expect
(
channel
).
toEqual
(
"
y-js
"
)
expect
(
message
.
message
instanceof
Uint8Array
).
toBe
(
true
)
...
...
@@ -338,7 +338,7 @@ describe("drawing app mesh", () => {
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
// Erase the dot
path
// Erase the dot
broadcastListener
.
callback
=
(
channel
,
message
)
=>
{
expect
(
channel
).
toEqual
(
"
y-js
"
)
expect
(
message
.
message
instanceof
Uint8Array
).
toBe
(
true
)
...
...
@@ -434,9 +434,6 @@ describe("drawing app mesh", () => {
()
=>
new
Promise
((
resolve
)
=>
{
// Replay the erase updates
expect
(
updatePaths
).
toStrictEqual
({
[
dotID
]:
dotDraw
})
expect
(
updateIntervals
).
toStrictEqual
({
[
dotID
]:
{}
})
updateRoom
.
addEventListener
(
"
removedIntervalsChange
"
,
({
detail
:
{
id
,
intervals
}
})
=>
{
...
...
@@ -561,7 +558,7 @@ describe("drawing app mesh", () => {
if
(
broadcasts
<
ITERATIONS
)
{
const
tmpPathID
=
room
.
addPath
(
pathDraw
[
0
])
pathIDs
.
push
(
tmpPathID
)
for
(
let
i
=
1
;
i
<
pathDraw
.
lenth
;
i
++
)
{
for
(
let
i
=
1
;
i
<
pathDraw
.
len
g
th
;
i
++
)
{
room
.
extendPath
(
tmpPathID
,
pathDraw
[
i
])
}
}
else
if
(
broadcasts
<
ITERATIONS
*
2
)
{
...
...
@@ -584,7 +581,7 @@ describe("drawing app mesh", () => {
const
tmpPathID
=
room
.
addPath
(
pathDraw
[
0
])
pathIDs
.
push
(
tmpPathID
)
for
(
let
i
=
1
;
i
<
pathDraw
.
lenth
;
i
++
)
{
for
(
let
i
=
1
;
i
<
pathDraw
.
len
g
th
;
i
++
)
{
room
.
extendPath
(
tmpPathID
,
pathDraw
[
i
])
}
}).
then
(
...
...
@@ -667,7 +664,7 @@ describe("drawing app mesh", () => {
for
(
let
j
=
0
;
j
<
ITERATIONS
;
j
++
)
{
const
tmpPathID
=
room
.
addPath
(
pathDraw
[
0
])
pathIDs
.
push
(
tmpPathID
)
for
(
let
i
=
1
;
i
<
pathDraw
.
lenth
;
i
++
)
{
for
(
let
i
=
1
;
i
<
pathDraw
.
len
g
th
;
i
++
)
{
room
.
extendPath
(
tmpPathID
,
pathDraw
[
i
])
}
}
...
...
@@ -758,34 +755,50 @@ describe("drawing app mesh", () => {
})
it
(
"
communicates a path draw and erase update
"
,
()
=>
{
jest
.
setTimeout
(
15000
)
let
pathID
let
syncPackets
=
0
const
addPackets
=
[]
const
erasePackets
=
[]
const
syncPackets
=
[]
let
syncDonePacket
=
-
1
const
updatePaths
=
{}
const
updateIntervals
=
{}
const
syncPaths
=
{}
const
syncIntervals
=
{}
let
timeout
return
new
Promise
((
resolve
)
=>
{
// Draw the path
broadcastListener
.
callback
=
(
channel
,
message
)
=>
{
expect
(
channel
).
toEqual
(
"
y-js
"
)
expect
(
message
.
message
instanceof
Uint8Array
).
toBe
(
true
)
addPackets
.
push
(
message
)
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
}
pathID
=
room
.
addPath
(
pathDraw
[
0
])
for
(
let
i
=
1
;
i
<
pathDraw
.
lenth
;
i
++
)
{
for
(
let
i
=
1
;
i
<
pathDraw
.
length
;
i
++
)
{
room
.
getPathPoints
(
pathID
)
room
.
extendPath
(
pathID
,
pathDraw
[
i
])
}
})
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
// Erase the path
broadcastListener
.
callback
=
(
channel
,
message
)
=>
{
expect
(
channel
).
toEqual
(
"
y-js
"
)
expect
(
message
.
message
instanceof
Uint8Array
).
toBe
(
true
)
erasePackets
.
push
(
message
)
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
}
...
...
@@ -802,12 +815,13 @@ describe("drawing app mesh", () => {
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
// Request a sync step 2
sendListener
.
callback
=
(
uid
,
channel
,
message
)
=>
{
expect
(
uid
).
toEqual
(
"
moritz
"
)
expect
(
channel
).
toEqual
(
"
y-js
"
)
expect
(
message
.
message
instanceof
Uint8Array
).
toBe
(
true
)
syncPackets
+=
1
syncPackets
.
push
(
message
)
if
(
message
.
message
.
length
==
syncDone
.
message
.
length
&&
...
...
@@ -816,12 +830,12 @@ describe("drawing app mesh", () => {
)
{
expect
(
syncDonePacket
).
toEqual
(
-
1
)
syncDonePacket
=
syncPackets
syncDonePacket
=
syncPackets
.
length
}
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
{
expect
(
syncDonePacket
).
toEqual
(
syncPackets
)
expect
(
syncDonePacket
).
toEqual
(
syncPackets
.
length
)
resolve
()
},
1000
)
...
...
@@ -833,5 +847,131 @@ describe("drawing app mesh", () => {
)(
createMessageReceivedEvent
(
syncStep1
))
}),
)
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
// Replay the draw updates
updateRoom
.
addEventListener
(
"
addOrUpdatePath
"
,
({
detail
:
{
id
,
points
}
})
=>
{
updatePaths
[
id
]
=
points
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
},
)
updateRoom
.
addEventListener
(
"
removedIntervalsChange
"
,
({
detail
:
{
id
,
intervals
}
})
=>
{
updateIntervals
[
id
]
=
intervals
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
},
)
for
(
const
addPacket
of
addPackets
)
{
getEventListener
(
"
update
"
,
"
messageReceived
"
,
)(
createMessageReceivedEvent
(
addPacket
))
}
}),
)
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
// Check the draw updates
expect
(
updatePaths
).
toStrictEqual
({
[
pathID
]:
pathDraw
})
expect
(
updateIntervals
).
toStrictEqual
({
[
pathID
]:
{}
})
resolve
()
}),
)
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
// Replay the erase updates
updateRoom
.
addEventListener
(
"
removedIntervalsChange
"
,
({
detail
:
{
id
,
intervals
}
})
=>
{
updateIntervals
[
id
]
=
intervals
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
},
)
for
(
const
erasePacket
of
erasePackets
)
{
getEventListener
(
"
update
"
,
"
messageReceived
"
,
)(
createMessageReceivedEvent
(
erasePacket
))
}
}),
)
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
// Check the erase updates
expect
(
updatePaths
).
toStrictEqual
({
[
pathID
]:
pathDraw
})
expect
(
updateIntervals
).
toStrictEqual
({
[
pathID
]:
Object
.
assign
(
{},
new
Array
(
pathDraw
.
length
).
fill
([[
0
,
1
]]),
),
})
resolve
()
}),
)
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
// Replay the synchronisation
syncRoom
.
addEventListener
(
"
addOrUpdatePath
"
,
({
detail
:
{
id
,
points
}
})
=>
{
syncPaths
[
id
]
=
points
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
},
)
syncRoom
.
addEventListener
(
"
removedIntervalsChange
"
,
({
detail
:
{
id
,
intervals
}
})
=>
{
syncIntervals
[
id
]
=
intervals
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
},
)
for
(
const
syncPacket
of
syncPackets
)
{
getEventListener
(
"
sync
"
,
"
messageReceived
"
,
)(
createMessageReceivedEvent
(
syncPacket
))
}
}),
)
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
// Check the synchronisation
expect
(
syncPaths
).
toStrictEqual
({
[
pathID
]:
pathDraw
})
expect
(
syncIntervals
).
toStrictEqual
({
[
pathID
]:
Object
.
assign
(
{},
new
Array
(
pathDraw
.
length
).
fill
([[
0
,
1
]]),
),
})
resolve
()
}),
)
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment