[geary/wip/781488-aliyun-greeting-error: 4/7] Add test case stub for Geary.Imap.Deserializer to the build.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/781488-aliyun-greeting-error: 4/7] Add test case stub for Geary.Imap.Deserializer to the build.
- Date: Tue, 31 Oct 2017 07:20:41 +0000 (UTC)
commit fc68c0d7d5dfd70822f255f66f90daf825164515
Author: Michael James Gratton <mike vee net>
Date: Mon Oct 30 11:56:13 2017 +1100
Add test case stub for Geary.Imap.Deserializer to the build.
test/CMakeLists.txt | 1 +
.../imap/transport/imap-deserializer-test.vala | 82 ++++++++++++++++++++
test/main.vala | 1 +
3 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 065435e..3733df6 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -8,6 +8,7 @@ set(TEST_SRC
engine/api/geary-attachment-test.vala
engine/api/geary-engine-test.vala
+ engine/imap/transport/imap-deserializer-test.vala
engine/mime-content-type-test.vala
engine/rfc822-mailbox-address-test.vala
engine/rfc822-message-test.vala
diff --git a/test/engine/imap/transport/imap-deserializer-test.vala
b/test/engine/imap/transport/imap-deserializer-test.vala
new file mode 100644
index 0000000..59fc3ae
--- /dev/null
+++ b/test/engine/imap/transport/imap-deserializer-test.vala
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2017 Michael Gratton <mike vee net>
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+class Geary.Imap.DeserializerTest : Gee.TestCase {
+
+
+ protected enum Expect { MESSAGE, EOS, DESER_FAIL; }
+
+ private const string ID = "test";
+ private const string EOL = "\r\n";
+
+ private Deserializer? deser = null;
+ private MemoryInputStream? stream = null;
+
+
+ public DeserializerTest() {
+ base("Geary.Imap.DeserializerTest");
+ }
+
+ public override void set_up() {
+ this.stream = new MemoryInputStream();
+ this.deser = new Deserializer(ID, this.stream);
+ }
+
+ public override void tear_down() {
+ this.deser.stop_async.begin((obj, ret) => { async_complete(ret); });
+ async_result();
+ }
+
+ protected async RootParameters? process(Expect expected) {
+ RootParameters? message = null;
+ bool eos = false;
+ bool deserialize_failure = false;
+ bool receive_failure = false;
+ size_t bytes_received = 0;
+
+ this.deser.parameters_ready.connect((param) => { message = param; });
+ this.deser.bytes_received.connect((count) => { bytes_received += count; });
+ this.deser.eos.connect((param) => { eos = true; });
+ this.deser.deserialize_failure.connect(() => { deserialize_failure = true; });
+ this.deser.receive_failure.connect((err) => { receive_failure = true;});
+
+ this.deser.start_async.begin();
+ while (message == null && !receive_failure && !eos && !deserialize_failure) {
+ this.main_loop.iteration(true);
+ }
+
+ switch (expected) {
+ case Expect.MESSAGE:
+ assert(message != null);
+ assert(bytes_received > 0);
+ assert(!eos);
+ assert(!deserialize_failure);
+ assert(!receive_failure);
+ break;
+
+ case Expect.EOS:
+ assert(message == null);
+ assert(eos);
+ assert(!deserialize_failure);
+ assert(!receive_failure);
+ break;
+
+ case Expect.DESER_FAIL:
+ assert(message == null);
+ assert(!eos);
+ assert(deserialize_failure);
+ assert(!receive_failure);
+ break;
+
+ default:
+ assert_not_reached();
+ }
+
+ return message;
+ }
+
+}
diff --git a/test/main.vala b/test/main.vala
index b959602..d873986 100644
--- a/test/main.vala
+++ b/test/main.vala
@@ -40,6 +40,7 @@ int main(string[] args) {
engine.add_suite(new Geary.AttachmentTest().get_suite());
engine.add_suite(new Geary.EngineTest().get_suite());
engine.add_suite(new Geary.HTML.UtilTest().get_suite());
+ engine.add_suite(new Geary.Imap.DeserializerTest().get_suite());
engine.add_suite(new Geary.IdleManagerTest().get_suite());
engine.add_suite(new Geary.Inet.Test().get_suite());
engine.add_suite(new Geary.JS.Test().get_suite());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]