From 2a514d0969f5c25d5e2d14421125a47df6b14974 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Fri, 17 Nov 2017 16:06:54 +0100 Subject: [PATCH] Fix unit tests using async + read message marker --- .../counterpart_interaction_manager.vala | 8 +----- .../conference_details_fragment.vala | 2 +- .../chat_state_populator.vala | 2 +- .../openpgp/src/account_settings_widget.vala | 2 +- xmpp-vala/src/module/message/module.vala | 5 ++-- xmpp-vala/tests/stanza.vala | 28 +++++++++---------- 6 files changed, 21 insertions(+), 26 deletions(-) diff --git a/libdino/src/service/counterpart_interaction_manager.vala b/libdino/src/service/counterpart_interaction_manager.vala index 75d2d7be..0b989c35 100644 --- a/libdino/src/service/counterpart_interaction_manager.vala +++ b/libdino/src/service/counterpart_interaction_manager.vala @@ -14,7 +14,6 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object { public signal void received_message_displayed(Account account, Jid jid, Entities.Message message); private StreamInteractor stream_interactor; - private HashMap last_read = new HashMap(Jid.hash_bare_func, Jid.equals_bare_func); private HashMap chat_states = new HashMap(Jid.hash_bare_func, Jid.equals_bare_func); public static void start(StreamInteractor stream_interactor) { @@ -32,10 +31,6 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object { 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) { 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); @@ -63,7 +58,6 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object { message.marked = Entities.Message.Marked.RECEIVED; break; case Xep.ChatMarkers.MARKER_DISPLAYED: - last_read[jid] = message; received_message_displayed(account, jid, message); Gee.List messages = stream_interactor.get_module(MessageStorage.IDENTITY).get_messages(conversation); foreach (Entities.Message m in messages) { @@ -85,4 +79,4 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object { on_chat_marker_received(account, jid, Xep.ChatMarkers.MARKER_RECEIVED, id); } } -} \ No newline at end of file +} diff --git a/main/src/ui/add_conversation/conference_details_fragment.vala b/main/src/ui/add_conversation/conference_details_fragment.vala index fbe9245d..027483f4 100644 --- a/main/src/ui/add_conversation/conference_details_fragment.vala +++ b/main/src/ui/add_conversation/conference_details_fragment.vala @@ -102,7 +102,7 @@ protected class ConferenceDetailsFragment : Box { stream_interactor.get_module(MucManager.IDENTITY).enter_error.connect(on_enter_error); notification_button.clicked.connect(() => { notification_revealer.set_reveal_child(false); }); ok_button.clicked.connect(() => { - ok_button.label = _("Joining..."); + ok_button.label = _("Joining…"); ok_button.sensitive = false; }); } diff --git a/main/src/ui/conversation_summary/chat_state_populator.vala b/main/src/ui/conversation_summary/chat_state_populator.vala index 6f397249..bb9597e6 100644 --- a/main/src/ui/conversation_summary/chat_state_populator.vala +++ b/main/src/ui/conversation_summary/chat_state_populator.vala @@ -54,7 +54,7 @@ class ChatStatePopulator : Plugins.ConversationItemPopulator, Object { if (state_ != null) { if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING || state_ == Xep.ChatStateNotifications.STATE_PAUSED) { if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING) { - new_text = _("is typing..."); + new_text = _("is typing…"); } else if (state_ == Xep.ChatStateNotifications.STATE_PAUSED) { new_text = _("has stopped typing"); } diff --git a/plugins/openpgp/src/account_settings_widget.vala b/plugins/openpgp/src/account_settings_widget.vala index e5f5aaf1..b71a1eda 100644 --- a/plugins/openpgp/src/account_settings_widget.vala +++ b/plugins/openpgp/src/account_settings_widget.vala @@ -95,7 +95,7 @@ private class AccountSettingsWidget : Stack, Plugins.AccountSettingsWidget { TreeIter iter; list_store.clear(); 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 (null, () => { // Querying GnuPG might take some time try { keys = GPGHelper.get_keylist(null, true); diff --git a/xmpp-vala/src/module/message/module.vala b/xmpp-vala/src/module/message/module.vala index 2ca06dc4..afa3f005 100644 --- a/xmpp-vala/src/module/message/module.vala +++ b/xmpp-vala/src/module/message/module.vala @@ -15,8 +15,9 @@ namespace Xmpp.Message { public signal void received_message(XmppStream stream, Message.Stanza message); public void send_message(XmppStream stream, Message.Stanza message) { - send_pipeline.run.begin(stream, message); - stream.write(message.stanza); + send_pipeline.run.begin(stream, message, (obj, res) => { + stream.write(message.stanza); + }); } public async void received_message_stanza_async(XmppStream stream, StanzaNode node) { diff --git a/xmpp-vala/tests/stanza.vala b/xmpp-vala/tests/stanza.vala index 1662c9bc..40b54a38 100644 --- a/xmpp-vala/tests/stanza.vala +++ b/xmpp-vala/tests/stanza.vala @@ -6,12 +6,12 @@ class StanzaTest : Gee.TestCase { public StanzaTest() { base("Stanza"); - add_test("node_one", test_node_one); - add_test("typical_stream", test_typical_stream); - add_test("ack_stream", test_ack_stream); + add_test("node_one", () => { test_node_one.begin(); }); + add_test("typical_stream", () => { test_typical_stream.begin(); }); + 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") .add_self_xmlns() .put_attribute("ns2", "ns2_uri", XMLNS_URI) @@ -22,12 +22,12 @@ class StanzaTest : Gee.TestCase { .add_self_xmlns()); 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_eq_str(node1.to_string(), node2.to_string()); } - private void test_typical_stream() { + private async void test_typical_stream() { var stream = """ reader.read_node(), 3, "end of stream should be reached"); } - private void test_ack_stream() { + private async void test_ack_stream() { var stream = """ reader.read_node(), 3, "end of stream should be reached"); }