Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-09-11 20:18:20 +0400
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-09-11 20:18:20 +0400
commit1a320baad896b4f0d7ae6d5170f75d70a9b1020b (patch)
tree1dcf843f5750b2cd263d1da6c4e814f79fa1af77 /test
parentb8c98232b8a3e4e5224fbb54c2e26966fe442f62 (diff)
Add tests for Client State Indication support
Diffstat (limited to 'test')
-rw-r--r--test/ejabberd_SUITE.erl38
-rw-r--r--test/ejabberd_SUITE_data/ejabberd.yml3
-rw-r--r--test/suite.erl2
3 files changed, 43 insertions, 0 deletions
diff --git a/test/ejabberd_SUITE.erl b/test/ejabberd_SUITE.erl
index fbf2444b6..0cc5afec3 100644
--- a/test/ejabberd_SUITE.erl
+++ b/test/ejabberd_SUITE.erl
@@ -237,6 +237,8 @@ db_tests(mnesia) ->
[offline_master, offline_slave]},
{test_carbons, [parallel],
[carbons_master, carbons_slave]},
+ {test_client_state, [parallel],
+ [client_state_master, client_state_slave]},
{test_muc, [parallel],
[muc_master, muc_slave]},
{test_announce, [sequence],
@@ -1505,6 +1507,42 @@ carbons_slave(Config) ->
#presence{from = Peer, type = unavailable} = recv(),
disconnect(Config).
+client_state_master(Config) ->
+ Peer = ?config(slave, Config),
+ Presence = #presence{to = Peer},
+ Message = #message{to = Peer, thread = <<"1">>,
+ sub_els = [#chatstate_active{}]},
+ wait_for_slave(Config),
+ %% Should be queued (but see below):
+ send(Config, Presence),
+ %% Should be sent immediately, together with the previous presence:
+ send(Config, Message#message{body = [#text{data = <<"body">>}]}),
+ %% Should be dropped:
+ send(Config, Message),
+ %% Should be queued (but see below):
+ send(Config, Presence),
+ %% Should replace the previous presence in the queue:
+ send(Config, Presence#presence{type = unavailable}),
+ wait_for_slave(Config),
+ %% Should be sent immediately, as the client is active again.
+ send(Config, Message),
+ disconnect(Config).
+
+client_state_slave(Config) ->
+ true = ?config(csi, Config),
+ Peer = ?config(master, Config),
+ send(Config, #csi_inactive{}),
+ wait_for_master(Config),
+ #presence{from = Peer, sub_els = [#delay{}]} = recv(),
+ #message{from = Peer, thread = <<"1">>, sub_els = [#chatstate_active{}],
+ body = [#text{data = <<"body">>}]} = recv(),
+ wait_for_master(Config),
+ send(Config, #csi_active{}),
+ ?recv2(#presence{from = Peer, type = unavailable, sub_els = [#delay{}]},
+ #message{from = Peer, thread = <<"1">>,
+ sub_els = [#chatstate_active{}]}),
+ disconnect(Config).
+
%%%===================================================================
%%% Aux functions
%%%===================================================================
diff --git a/test/ejabberd_SUITE_data/ejabberd.yml b/test/ejabberd_SUITE_data/ejabberd.yml
index f096fc53f..597ba5be7 100644
--- a/test/ejabberd_SUITE_data/ejabberd.yml
+++ b/test/ejabberd_SUITE_data/ejabberd.yml
@@ -143,6 +143,9 @@ Welcome to this XMPP server."
db_type: internal
mod_carboncopy:
db_type: internal
+ mod_client_state:
+ drop_chat_states: true
+ queue_presence: true
mod_adhoc: []
mod_configure: []
mod_disco: []
diff --git a/test/suite.erl b/test/suite.erl
index a1043526f..a50bb64df 100644
--- a/test/suite.erl
+++ b/test/suite.erl
@@ -155,6 +155,8 @@ wait_auth_SASL_result(Config) ->
lists:foldl(
fun(#feature_sm{}, ConfigAcc) ->
set_opt(sm, true, ConfigAcc);
+ (#feature_csi{}, ConfigAcc) ->
+ set_opt(csi, true, ConfigAcc);
(_, ConfigAcc) ->
ConfigAcc
end, Config, Fs);