Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
savoirfairelinux
jami-daemon
Commits
c16041fc
Commit
c16041fc
authored
3 years ago
by
Mohamed Chibani
Browse files
Options
Downloads
Patches
Plain Diff
ut_sip_basic_calls: enable scenario with all media disabled
Gitlab:
#570
Change-Id: I87f476082f0f04b342e737e523eae976b0717bca
parent
b34d1a3c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/unitTest/sip_account/sip_basic_calls.cpp
+67
-57
67 additions, 57 deletions
test/unitTest/sip_account/sip_basic_calls.cpp
with
67 additions
and
57 deletions
test/unitTest/sip_account/sip_basic_calls.cpp
+
67
−
57
View file @
c16041fc
...
...
@@ -85,17 +85,14 @@ private:
// Test cases.
void
audio_only_test
();
void
audio_video_test
();
void
peer_
disable_media
();
void
peer_
answer_with_all_media_disabled
();
CPPUNIT_TEST_SUITE
(
SipBasicCallTest
);
CPPUNIT_TEST
(
audio_only_test
);
CPPUNIT_TEST
(
audio_video_test
);
#if 0
// Test when the peer answers will all media disabled (RTP port = 0)
// For now, this test will cause a crash. Must be enabled once the
// crash is fixed
CPPUNIT_TEST(peer_disable_media);
#endif
// Test when the peer answers with all the media disabled (RTP port = 0)
CPPUNIT_TEST
(
peer_answer_with_all_media_disabled
);
CPPUNIT_TEST_SUITE_END
();
// Event/Signal handlers
...
...
@@ -113,6 +110,7 @@ private:
// Helpers
void
audio_video_call
(
std
::
vector
<
MediaAttribute
>
offer
,
std
::
vector
<
MediaAttribute
>
answer
,
bool
expectedToSucceed
=
true
,
bool
validateMedia
=
true
);
static
void
configureTest
(
CallData
&
bob
,
CallData
&
alice
);
static
std
::
string
getUserAlias
(
const
std
::
string
&
callId
);
...
...
@@ -314,7 +312,7 @@ SipBasicCallTest::waitForSignal(CallData& callData,
const
std
::
string
&
expectedSignal
,
const
std
::
string
&
expectedEvent
)
{
const
std
::
chrono
::
seconds
TIME_OUT
{
3
0
};
const
std
::
chrono
::
seconds
TIME_OUT
{
1
0
};
std
::
unique_lock
<
std
::
mutex
>
lock
{
callData
.
mtx_
};
// Combined signal + event (if any).
...
...
@@ -418,6 +416,7 @@ SipBasicCallTest::configureTest(CallData& aliceData, CallData& bobData)
void
SipBasicCallTest
::
audio_video_call
(
std
::
vector
<
MediaAttribute
>
offer
,
std
::
vector
<
MediaAttribute
>
answer
,
bool
expectedToSucceed
,
bool
validateMedia
)
{
JAMI_INFO
(
"=== Begin test %s ==="
,
__FUNCTION__
);
...
...
@@ -452,58 +451,69 @@ SipBasicCallTest::audio_video_call(std::vector<MediaAttribute> offer,
// Answer the call.
DRing
::
acceptWithMedia
(
bobData_
.
callId_
,
MediaAttribute
::
mediaAttributesToMediaMaps
(
answer
));
// Wait for media negotiation complete signal.
CPPUNIT_ASSERT
(
waitForSignal
(
bobData_
,
DRing
::
CallSignal
::
MediaNegotiationStatus
::
name
,
DRing
::
Media
::
MediaNegotiationStatusEvents
::
NEGOTIATION_SUCCESS
));
// Wait for the StateChange signal.
CPPUNIT_ASSERT
(
waitForSignal
(
bobData_
,
DRing
::
CallSignal
::
StateChange
::
name
,
StateEvent
::
CURRENT
));
JAMI_INFO
(
"BOB answered the call [%s]"
,
bobData_
.
callId_
.
c_str
());
// Wait for media negotiation complete signal.
CPPUNIT_ASSERT
(
waitForSignal
(
aliceData_
,
DRing
::
CallSignal
::
MediaNegotiationStatus
::
name
,
DRing
::
Media
::
MediaNegotiationStatusEvents
::
NEGOTIATION_SUCCESS
));
// Validate Alice's media
if
(
validateMedia
)
{
auto
activeMediaList
=
Manager
::
instance
().
getMediaAttributeList
(
aliceData_
.
callId_
);
CPPUNIT_ASSERT_EQUAL
(
offer
.
size
(),
activeMediaList
.
size
());
// Audio
CPPUNIT_ASSERT_EQUAL
(
MediaType
::
MEDIA_AUDIO
,
activeMediaList
[
0
].
type_
);
CPPUNIT_ASSERT_EQUAL
(
offer
[
0
].
enabled_
,
activeMediaList
[
0
].
enabled_
);
// Video
if
(
offer
.
size
()
>
1
)
{
CPPUNIT_ASSERT_EQUAL
(
MediaType
::
MEDIA_VIDEO
,
activeMediaList
[
1
].
type_
);
CPPUNIT_ASSERT_EQUAL
(
offer
[
1
].
enabled_
,
activeMediaList
[
1
].
enabled_
);
if
(
expectedToSucceed
)
{
// Wait for media negotiation complete signal.
CPPUNIT_ASSERT
(
waitForSignal
(
bobData_
,
DRing
::
CallSignal
::
MediaNegotiationStatus
::
name
,
DRing
::
Media
::
MediaNegotiationStatusEvents
::
NEGOTIATION_SUCCESS
));
// Wait for the StateChange signal.
CPPUNIT_ASSERT
(
waitForSignal
(
bobData_
,
DRing
::
CallSignal
::
StateChange
::
name
,
StateEvent
::
CURRENT
));
JAMI_INFO
(
"BOB answered the call [%s]"
,
bobData_
.
callId_
.
c_str
());
// Wait for media negotiation complete signal.
CPPUNIT_ASSERT
(
waitForSignal
(
aliceData_
,
DRing
::
CallSignal
::
MediaNegotiationStatus
::
name
,
DRing
::
Media
::
MediaNegotiationStatusEvents
::
NEGOTIATION_SUCCESS
));
// Validate Alice's media
if
(
validateMedia
)
{
auto
activeMediaList
=
Manager
::
instance
().
getMediaAttributeList
(
aliceData_
.
callId_
);
CPPUNIT_ASSERT_EQUAL
(
offer
.
size
(),
activeMediaList
.
size
());
// Audio
CPPUNIT_ASSERT_EQUAL
(
MediaType
::
MEDIA_AUDIO
,
activeMediaList
[
0
].
type_
);
CPPUNIT_ASSERT_EQUAL
(
offer
[
0
].
enabled_
,
activeMediaList
[
0
].
enabled_
);
// Video
if
(
offer
.
size
()
>
1
)
{
CPPUNIT_ASSERT_EQUAL
(
MediaType
::
MEDIA_VIDEO
,
activeMediaList
[
1
].
type_
);
CPPUNIT_ASSERT_EQUAL
(
offer
[
1
].
enabled_
,
activeMediaList
[
1
].
enabled_
);
}
}
}
// Validate Bob's media
if
(
validateMedia
)
{
auto
activeMediaList
=
Manager
::
instance
().
getMediaAttributeList
(
bobData_
.
callId_
);
CPPUNIT_ASSERT_EQUAL
(
answer
.
size
(),
activeMediaList
.
size
());
// Audio
CPPUNIT_ASSERT_EQUAL
(
MediaType
::
MEDIA_AUDIO
,
activeMediaList
[
0
].
type_
);
CPPUNIT_ASSERT_EQUAL
(
answer
[
0
].
enabled_
,
activeMediaList
[
0
].
enabled_
);
// Video
if
(
offer
.
size
()
>
1
)
{
CPPUNIT_ASSERT_EQUAL
(
MediaType
::
MEDIA_VIDEO
,
activeMediaList
[
1
].
type_
);
CPPUNIT_ASSERT_EQUAL
(
answer
[
1
].
enabled_
,
activeMediaList
[
1
].
enabled_
);
// Validate Bob's media
if
(
validateMedia
)
{
auto
activeMediaList
=
Manager
::
instance
().
getMediaAttributeList
(
bobData_
.
callId_
);
CPPUNIT_ASSERT_EQUAL
(
answer
.
size
(),
activeMediaList
.
size
());
// Audio
CPPUNIT_ASSERT_EQUAL
(
MediaType
::
MEDIA_AUDIO
,
activeMediaList
[
0
].
type_
);
CPPUNIT_ASSERT_EQUAL
(
answer
[
0
].
enabled_
,
activeMediaList
[
0
].
enabled_
);
// Video
if
(
offer
.
size
()
>
1
)
{
CPPUNIT_ASSERT_EQUAL
(
MediaType
::
MEDIA_VIDEO
,
activeMediaList
[
1
].
type_
);
CPPUNIT_ASSERT_EQUAL
(
answer
[
1
].
enabled_
,
activeMediaList
[
1
].
enabled_
);
}
}
}
// Give some time to media to start and flow
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
3
));
// Give some time to media to start and flow
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
3
));
// Bob hang-up.
JAMI_INFO
(
"Hang up BOB's call and wait for ALICE to hang up"
);
DRing
::
hangUp
(
bobData_
.
callId_
);
}
else
{
// The media negotiation for the call is expected to fail, so we
// should receive the signal.
CPPUNIT_ASSERT
(
waitForSignal
(
bobData_
,
DRing
::
CallSignal
::
StateChange
::
name
,
StateEvent
::
FAILURE
));
}
// Bob hang-up.
JAMI_INFO
(
"Hang up BOB's call and wait for ALICE to hang up"
);
DRing
::
hangUp
(
bobData_
.
callId_
);
// The hang-up signal will be emitted on caller's side (Alice) in both
// success failure scenarios.
CPPUNIT_ASSERT
(
waitForSignal
(
aliceData_
,
DRing
::
CallSignal
::
StateChange
::
name
,
StateEvent
::
HUNGUP
));
...
...
@@ -587,7 +597,7 @@ SipBasicCallTest::audio_video_test()
}
void
SipBasicCallTest
::
peer_
disable_media
()
SipBasicCallTest
::
peer_
answer_with_all_media_disabled
()
{
auto
const
bobAcc
=
Manager
::
instance
().
getAccount
<
SIPAccount
>
(
bobData_
.
accountId_
);
...
...
@@ -610,7 +620,7 @@ SipBasicCallTest::peer_disable_media()
answer
.
emplace_back
(
video
);
// Run the scenario
audio_video_call
(
offer
,
answer
,
false
);
audio_video_call
(
offer
,
answer
,
false
,
false
);
}
}
// namespace test
...
...
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