Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mtxclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Nheko Reborn
mtxclient
Commits
55f57c62
Unverified
Commit
55f57c62
authored
4 years ago
by
Nicolas Werner
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #52 from Nheko-Reborn/fix-voip-tests
Fix voip tests with string version
parents
53f8883a
60fe89d0
No related branches found
No related tags found
No related merge requests found
Pipeline
#798
passed
4 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/structs/events/voip.cpp
+15
-6
15 additions, 6 deletions
lib/structs/events/voip.cpp
tests/messages.cpp
+4
-4
4 additions, 4 deletions
tests/messages.cpp
with
19 additions
and
10 deletions
lib/structs/events/voip.cpp
+
15
−
6
View file @
55f57c62
...
...
@@ -13,6 +13,15 @@ version(const json &obj)
auto
v
=
obj
.
at
(
"version"
);
return
v
.
is_number
()
?
"0"
:
v
.
get
<
std
::
string
>
();
}
void
add_version
(
json
&
obj
,
std
::
string_view
version
)
{
if
(
version
==
"0"
)
obj
[
"version"
]
=
0
;
else
obj
[
"version"
]
=
version
;
}
}
namespace
mtx
::
events
::
msg
{
...
...
@@ -30,9 +39,9 @@ from_json(const json &obj, CallInvite &content)
void
to_json
(
json
&
obj
,
const
CallInvite
&
content
)
{
obj
[
"call_id"
]
=
content
.
call_id
;
obj
[
"offer"
]
=
{{
"sdp"
,
content
.
sdp
},
{
"type"
,
"offer"
}};
obj
[
"
version
"
]
=
content
.
version
;
obj
[
"call_id"
]
=
content
.
call_id
;
obj
[
"offer"
]
=
{{
"sdp"
,
content
.
sdp
},
{
"type"
,
"offer"
}};
add_
version
(
obj
,
content
.
version
)
;
obj
[
"lifetime"
]
=
content
.
lifetime
;
}
...
...
@@ -66,7 +75,7 @@ to_json(json &obj, const CallCandidates &content)
{
obj
[
"call_id"
]
=
content
.
call_id
;
obj
[
"candidates"
]
=
content
.
candidates
;
obj
[
"
version
"
]
=
content
.
version
;
add_
version
(
obj
,
content
.
version
)
;
}
// m.call.answer
...
...
@@ -83,7 +92,7 @@ to_json(json &obj, const CallAnswer &content)
{
obj
[
"call_id"
]
=
content
.
call_id
;
obj
[
"answer"
]
=
{{
"sdp"
,
content
.
sdp
},
{
"type"
,
"answer"
}};
obj
[
"
version
"
]
=
content
.
version
;
add_
version
(
obj
,
content
.
version
)
;
}
// m.call.hangup
...
...
@@ -106,7 +115,7 @@ void
to_json
(
json
&
obj
,
const
CallHangUp
&
content
)
{
obj
[
"call_id"
]
=
content
.
call_id
;
obj
[
"
version
"
]
=
content
.
version
;
add_
version
(
obj
,
content
.
version
)
;
if
(
content
.
reason
==
CallHangUp
::
Reason
::
ICEFailed
)
obj
[
"reason"
]
=
"ice_failed"
;
else
if
(
content
.
reason
==
CallHangUp
::
Reason
::
InviteTimeOut
)
...
...
This diff is collapsed.
Click to expand it.
tests/messages.cpp
+
4
−
4
View file @
55f57c62
...
...
@@ -801,7 +801,7 @@ TEST(RoomEvents, CallInvite)
EXPECT_EQ
(
event
.
unsigned_data
.
age
,
1234
);
EXPECT_EQ
(
event
.
content
.
call_id
,
"c1591052749788"
);
EXPECT_EQ
(
event
.
content
.
sdp
,
"v=0
\r\n
o=- 6584580628695956864 2 IN IP4 127.0.0.1[...]"
);
EXPECT_EQ
(
event
.
content
.
version
,
0
);
EXPECT_EQ
(
event
.
content
.
version
,
"0"
);
EXPECT_EQ
(
event
.
content
.
lifetime
,
120000
);
EXPECT_EQ
(
data
,
json
(
event
));
...
...
@@ -844,7 +844,7 @@ TEST(RoomEvents, CallCandidates)
EXPECT_EQ
(
event
.
content
.
candidates
[
0
].
sdpMLineIndex
,
0
);
EXPECT_EQ
(
event
.
content
.
candidates
[
0
].
candidate
,
"candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0"
);
EXPECT_EQ
(
event
.
content
.
version
,
0
);
EXPECT_EQ
(
event
.
content
.
version
,
"0"
);
EXPECT_EQ
(
data
,
json
(
event
));
}
...
...
@@ -880,7 +880,7 @@ TEST(RoomEvents, CallAnswer)
EXPECT_EQ
(
event
.
unsigned_data
.
age
,
1234
);
EXPECT_EQ
(
event
.
content
.
call_id
,
"c1591052749788"
);
EXPECT_EQ
(
event
.
content
.
sdp
,
"v=0
\r\n
o=- 6584580628695956864 2 IN IP4 127.0.0.1[...]"
);
EXPECT_EQ
(
event
.
content
.
version
,
0
);
EXPECT_EQ
(
event
.
content
.
version
,
"0"
);
EXPECT_EQ
(
data
,
json
(
event
));
}
...
...
@@ -912,7 +912,7 @@ TEST(RoomEvents, CallHangUp)
EXPECT_EQ
(
event
.
type
,
EventType
::
CallHangUp
);
EXPECT_EQ
(
event
.
unsigned_data
.
age
,
1234
);
EXPECT_EQ
(
event
.
content
.
call_id
,
"c1591052749788"
);
EXPECT_EQ
(
event
.
content
.
version
,
0
);
EXPECT_EQ
(
event
.
content
.
version
,
"0"
);
EXPECT_EQ
(
event
.
content
.
reason
,
msg
::
CallHangUp
::
Reason
::
InviteTimeOut
);
EXPECT_EQ
(
data
,
json
(
event
));
...
...
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