Fix unit tests using async + read message marker
This commit is contained in:
parent
48cd057bd5
commit
2a514d0969
|
@ -14,7 +14,6 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object {
|
||||||
public signal void received_message_displayed(Account account, Jid jid, Entities.Message message);
|
public signal void received_message_displayed(Account account, Jid jid, Entities.Message message);
|
||||||
|
|
||||||
private StreamInteractor stream_interactor;
|
private StreamInteractor stream_interactor;
|
||||||
private HashMap<Jid, Entities.Message> last_read = new HashMap<Jid, Entities.Message>(Jid.hash_bare_func, Jid.equals_bare_func);
|
|
||||||
private HashMap<Jid, string> chat_states = new HashMap<Jid, string>(Jid.hash_bare_func, Jid.equals_bare_func);
|
private HashMap<Jid, string> chat_states = new HashMap<Jid, string>(Jid.hash_bare_func, Jid.equals_bare_func);
|
||||||
|
|
||||||
public static void start(StreamInteractor stream_interactor) {
|
public static void start(StreamInteractor stream_interactor) {
|
||||||
|
@ -32,10 +31,6 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object {
|
||||||
return chat_states[jid];
|
return chat_states[jid];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entities.Message? get_last_read(Account account, Jid jid) {
|
|
||||||
return last_read[jid];
|
|
||||||
}
|
|
||||||
|
|
||||||
private void on_account_added(Account account) {
|
private void on_account_added(Account account) {
|
||||||
stream_interactor.module_manager.get_module(account, Xep.ChatMarkers.Module.IDENTITY).marker_received.connect( (stream, jid, marker, id) => {
|
stream_interactor.module_manager.get_module(account, Xep.ChatMarkers.Module.IDENTITY).marker_received.connect( (stream, jid, marker, id) => {
|
||||||
on_chat_marker_received(account, new Jid(jid), marker, id);
|
on_chat_marker_received(account, new Jid(jid), marker, id);
|
||||||
|
@ -63,7 +58,6 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object {
|
||||||
message.marked = Entities.Message.Marked.RECEIVED;
|
message.marked = Entities.Message.Marked.RECEIVED;
|
||||||
break;
|
break;
|
||||||
case Xep.ChatMarkers.MARKER_DISPLAYED:
|
case Xep.ChatMarkers.MARKER_DISPLAYED:
|
||||||
last_read[jid] = message;
|
|
||||||
received_message_displayed(account, jid, message);
|
received_message_displayed(account, jid, message);
|
||||||
Gee.List<Entities.Message> messages = stream_interactor.get_module(MessageStorage.IDENTITY).get_messages(conversation);
|
Gee.List<Entities.Message> messages = stream_interactor.get_module(MessageStorage.IDENTITY).get_messages(conversation);
|
||||||
foreach (Entities.Message m in messages) {
|
foreach (Entities.Message m in messages) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ protected class ConferenceDetailsFragment : Box {
|
||||||
stream_interactor.get_module(MucManager.IDENTITY).enter_error.connect(on_enter_error);
|
stream_interactor.get_module(MucManager.IDENTITY).enter_error.connect(on_enter_error);
|
||||||
notification_button.clicked.connect(() => { notification_revealer.set_reveal_child(false); });
|
notification_button.clicked.connect(() => { notification_revealer.set_reveal_child(false); });
|
||||||
ok_button.clicked.connect(() => {
|
ok_button.clicked.connect(() => {
|
||||||
ok_button.label = _("Joining...");
|
ok_button.label = _("Joining…");
|
||||||
ok_button.sensitive = false;
|
ok_button.sensitive = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ChatStatePopulator : Plugins.ConversationItemPopulator, Object {
|
||||||
if (state_ != null) {
|
if (state_ != null) {
|
||||||
if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING || state_ == Xep.ChatStateNotifications.STATE_PAUSED) {
|
if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING || state_ == Xep.ChatStateNotifications.STATE_PAUSED) {
|
||||||
if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING) {
|
if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING) {
|
||||||
new_text = _("is typing...");
|
new_text = _("is typing…");
|
||||||
} else if (state_ == Xep.ChatStateNotifications.STATE_PAUSED) {
|
} else if (state_ == Xep.ChatStateNotifications.STATE_PAUSED) {
|
||||||
new_text = _("has stopped typing");
|
new_text = _("has stopped typing");
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ private class AccountSettingsWidget : Stack, Plugins.AccountSettingsWidget {
|
||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
list_store.clear();
|
list_store.clear();
|
||||||
list_store.append(out iter);
|
list_store.append(out iter);
|
||||||
label.set_markup(build_markup_string(_("Loading..."), _("Querying GnuPG")));
|
label.set_markup(build_markup_string(_("Loading…"), _("Querying GnuPG")));
|
||||||
new Thread<void*> (null, () => { // Querying GnuPG might take some time
|
new Thread<void*> (null, () => { // Querying GnuPG might take some time
|
||||||
try {
|
try {
|
||||||
keys = GPGHelper.get_keylist(null, true);
|
keys = GPGHelper.get_keylist(null, true);
|
||||||
|
|
|
@ -15,8 +15,9 @@ namespace Xmpp.Message {
|
||||||
public signal void received_message(XmppStream stream, Message.Stanza message);
|
public signal void received_message(XmppStream stream, Message.Stanza message);
|
||||||
|
|
||||||
public void send_message(XmppStream stream, Message.Stanza message) {
|
public void send_message(XmppStream stream, Message.Stanza message) {
|
||||||
send_pipeline.run.begin(stream, message);
|
send_pipeline.run.begin(stream, message, (obj, res) => {
|
||||||
stream.write(message.stanza);
|
stream.write(message.stanza);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void received_message_stanza_async(XmppStream stream, StanzaNode node) {
|
public async void received_message_stanza_async(XmppStream stream, StanzaNode node) {
|
||||||
|
|
|
@ -6,12 +6,12 @@ class StanzaTest : Gee.TestCase {
|
||||||
public StanzaTest() {
|
public StanzaTest() {
|
||||||
base("Stanza");
|
base("Stanza");
|
||||||
|
|
||||||
add_test("node_one", test_node_one);
|
add_test("node_one", () => { test_node_one.begin(); });
|
||||||
add_test("typical_stream", test_typical_stream);
|
add_test("typical_stream", () => { test_typical_stream.begin(); });
|
||||||
add_test("ack_stream", test_ack_stream);
|
add_test("ack_stream", () => { test_ack_stream.begin(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void test_node_one() {
|
private async void test_node_one() {
|
||||||
var node1 = new StanzaNode.build("test", "ns1_uri")
|
var node1 = new StanzaNode.build("test", "ns1_uri")
|
||||||
.add_self_xmlns()
|
.add_self_xmlns()
|
||||||
.put_attribute("ns2", "ns2_uri", XMLNS_URI)
|
.put_attribute("ns2", "ns2_uri", XMLNS_URI)
|
||||||
|
@ -22,12 +22,12 @@ class StanzaTest : Gee.TestCase {
|
||||||
.add_self_xmlns());
|
.add_self_xmlns());
|
||||||
|
|
||||||
var xml1 = node1.to_xml();
|
var xml1 = node1.to_xml();
|
||||||
var node2 = new StanzaReader.for_string(xml1).read_node();
|
var node2 = yield new StanzaReader.for_string(xml1).read_node();
|
||||||
fail_if_not(node1.equals(node2));
|
fail_if_not(node1.equals(node2));
|
||||||
fail_if_not_eq_str(node1.to_string(), node2.to_string());
|
fail_if_not_eq_str(node1.to_string(), node2.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void test_typical_stream() {
|
private async void test_typical_stream() {
|
||||||
var stream = """
|
var stream = """
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<stream:stream
|
<stream:stream
|
||||||
|
@ -55,13 +55,13 @@ class StanzaTest : Gee.TestCase {
|
||||||
.put_node(new StanzaNode.text("I'll send a friar with speed, to Mantua, with my letters to thy lord.")));
|
.put_node(new StanzaNode.text("I'll send a friar with speed, to Mantua, with my letters to thy lord.")));
|
||||||
|
|
||||||
var reader = new StanzaReader.for_string(stream);
|
var reader = new StanzaReader.for_string(stream);
|
||||||
fail_if_not_eq_node(root_node_cmp, reader.read_root_node());
|
fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node());
|
||||||
fail_if_not_eq_node(node_cmp, reader.read_node());
|
fail_if_not_eq_node(node_cmp, yield reader.read_node());
|
||||||
reader.read_node();
|
yield reader.read_node();
|
||||||
fail_if_not_error_code(() => reader.read_node(), 3, "end of stream should be reached");
|
fail_if_not_error_code(() => reader.read_node(), 3, "end of stream should be reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void test_ack_stream() {
|
private async void test_ack_stream() {
|
||||||
var stream = """
|
var stream = """
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<stream:stream
|
<stream:stream
|
||||||
|
@ -93,10 +93,10 @@ class StanzaTest : Gee.TestCase {
|
||||||
var node2_cmp = new StanzaNode.build("r", "http://jabber.org/protocol/ack");
|
var node2_cmp = new StanzaNode.build("r", "http://jabber.org/protocol/ack");
|
||||||
|
|
||||||
var reader = new StanzaReader.for_string(stream);
|
var reader = new StanzaReader.for_string(stream);
|
||||||
fail_if_not_eq_node(root_node_cmp, reader.read_root_node());
|
fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node());
|
||||||
fail_if_not_eq_node(node_cmp, reader.read_node());
|
fail_if_not_eq_node(node_cmp, yield reader.read_node());
|
||||||
fail_if_not_eq_node(node2_cmp, reader.read_node());
|
fail_if_not_eq_node(node2_cmp, yield reader.read_node());
|
||||||
reader.read_node();
|
yield reader.read_node();
|
||||||
fail_if_not_error_code(() => reader.read_node(), 3, "end of stream should be reached");
|
fail_if_not_error_code(() => reader.read_node(), 3, "end of stream should be reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue