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
46f180e2
Unverified
Commit
46f180e2
authored
1 year ago
by
Sébastien Blin
Browse files
Options
Downloads
Patches
Plain Diff
ut_conversationMembersEvent: little cleanup
Change-Id: I351016eecacd9357b4b0ad54adacbcd8d39f8731
parent
302a4322
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/conversation/conversationMembersEvent.cpp
+17
-40
17 additions, 40 deletions
test/unitTest/conversation/conversationMembersEvent.cpp
with
17 additions
and
40 deletions
test/unitTest/conversation/conversationMembersEvent.cpp
+
17
−
40
View file @
46f180e2
...
...
@@ -561,53 +561,26 @@ ConversationMembersEventTest::testAddOfflineMemberThenConnects()
void
ConversationMembersEventTest
::
testAddAcceptOfflineThenConnects
()
{
auto
aliceAccount
=
Manager
::
instance
().
getAccount
<
JamiAccount
>
(
aliceId
);
connectSignals
();
auto
bobAccount
=
Manager
::
instance
().
getAccount
<
JamiAccount
>
(
bobId
);
auto
bobUri
=
bobAccount
->
getUsername
();
auto
convId
=
libjami
::
startConversation
(
aliceId
);
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
libjami
::
CallbackWrapperBase
>>
confHandlers
;
bool
conversationReady
=
false
,
requestReceived
=
false
;
confHandlers
.
insert
(
libjami
::
exportable_callback
<
libjami
::
ConversationSignal
::
ConversationReady
>
(
[
&
](
const
std
::
string
&
accountId
,
const
std
::
string
&
/* conversationId */
)
{
if
(
accountId
==
bobId
)
{
conversationReady
=
true
;
cv
.
notify_one
();
}
}));
confHandlers
.
insert
(
libjami
::
exportable_callback
<
libjami
::
ConversationSignal
::
ConversationRequestReceived
>
(
[
&
](
const
std
::
string
&
/*accountId*/
,
const
std
::
string
&
/* conversationId */
,
std
::
map
<
std
::
string
,
std
::
string
>
/*metadatas*/
)
{
requestReceived
=
true
;
cv
.
notify_one
();
}));
bool
aliceStopped
=
false
;
confHandlers
.
insert
(
libjami
::
exportable_callback
<
libjami
::
ConfigurationSignal
::
VolatileDetailsChanged
>
(
[
&
](
const
std
::
string
&
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
)
{
auto
details
=
aliceAccount
->
getVolatileAccountDetails
();
auto
daemonStatus
=
details
[
libjami
::
Account
::
ConfProperties
::
Registration
::
STATUS
];
if
(
daemonStatus
==
"UNREGISTERED"
)
aliceStopped
=
true
;
cv
.
notify_one
();
}));
libjami
::
registerSignalHandlers
(
confHandlers
);
libjami
::
addConversationMember
(
aliceId
,
convId
,
bobUri
);
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
60s
,
[
&
]
{
return
requestReceived
;
}));
libjami
::
addConversationMember
(
aliceId
,
aliceData
.
conversationId
,
bobUri
);
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
60s
,
[
&
]
{
return
bobData
.
requestReceived
;
}));
Manager
::
instance
().
sendRegister
(
aliceId
,
false
);
// This avoid to sync immediately
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
60s
,
[
&
]
{
return
aliceStopped
;
}));
libjami
::
acceptConversationRequest
(
bobId
,
convId
);
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
60s
,
[
&
]
{
return
aliceData
.
stopped
;
}));
// Accepts
libjami
::
acceptConversationRequest
(
bobId
,
aliceData
.
conversationId
);
std
::
this_thread
::
sleep_for
(
40s
);
// Wait for negotiation to timeout
CPPUNIT_ASSERT
(
!
cv
.
wait_for
(
lk
,
60s
,
[
&
]()
{
return
!
bobData
.
conversationId
.
empty
();
}));
Manager
::
instance
().
sendRegister
(
aliceId
,
true
);
// This avoid to sync immediately
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
30s
,
[
&
]()
{
return
conversationReady
;
}));
libjami
::
unregisterSignalHandlers
();
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
60s
,
[
&
]()
{
return
!
bobData
.
conversationId
.
empty
();
}));
}
void
...
...
@@ -838,7 +811,6 @@ ConversationMembersEventTest::testBannedMemberCannotSendMessage()
// Now check that alice doesn't receive a message from Bob
libjami
::
sendMessage
(
bobId
,
convId
,
"hi"
s
,
""
);
CPPUNIT_ASSERT
(
!
cv
.
wait_for
(
lk
,
30s
,
[
&
]()
{
return
aliceMsgSize
+
4
==
aliceData
.
messages
.
size
();
}));
libjami
::
unregisterSignalHandlers
();
}
void
...
...
@@ -1059,7 +1031,6 @@ ConversationMembersEventTest::testCommitUnauthorizedUser()
libjami
::
sendMessage
(
bobId
,
convId
,
"hi"
s
,
""
);
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
30s
,
[
&
]()
{
return
aliceData
.
errorDetected
;
}));
libjami
::
unregisterSignalHandlers
();
}
void
...
...
@@ -1563,10 +1534,16 @@ ConversationMembersEventTest::testBanUnbanGotFirstConv()
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
30s
,
[
&
]()
{
return
bob2Data
.
contactRemoved
;
}));
// Alice sends messages, bob & bob2 should not get it!
aliceMsgSize
=
aliceData
.
messages
.
size
();
auto
bobMsgSize
=
bobData
.
messages
.
size
();
auto
bob2MsgSize
=
bob2Data
.
messages
.
size
();
libjami
::
sendMessage
(
aliceId
,
aliceData
.
conversationId
,
"hi"
s
,
""
);
CPPUNIT_ASSERT
(
!
cv
.
wait_for
(
lk
,
30s
,
[
&
]()
{
return
bobMsgSize
!=
bobData
.
messages
.
size
()
&&
bob2MsgSize
!=
bob2Data
.
messages
.
size
();
}));
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
30s
,
[
&
]()
{
return
aliceMsgSize
!=
aliceData
.
messages
.
size
();
}));
auto
msgId
=
aliceData
.
messages
.
rbegin
()
->
id
;
auto
getMessage
=
[](
const
auto
&
data
,
const
auto
&
mid
)
->
bool
{
return
std
::
find_if
(
data
.
messages
.
begin
(),
data
.
messages
.
end
(),
[
&
](
auto
&
msg
)
{
return
msg
.
id
==
mid
;
})
!=
data
.
messages
.
end
();
};
CPPUNIT_ASSERT
(
!
cv
.
wait_for
(
lk
,
30s
,
[
&
]()
{
return
getMessage
(
bobData
,
msgId
)
&&
getMessage
(
bob2Data
,
msgId
);
}));
// Bobs re-add Alice
bobAccount
->
addContact
(
aliceUri
);
...
...
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