Add API for (de)serialising FolderPath and EmailIdentifier
Supports (de)serialising via GLib.Variant for use as GLib.Action targets transmission via DBus, etc.
This commit is contained in:
parent
f269e552ae
commit
dd3a7a1bc8
14 changed files with 251 additions and 13 deletions
|
|
@ -120,6 +120,21 @@ public class Geary.MockAccount : Account, MockObject {
|
|||
}
|
||||
}
|
||||
|
||||
public override EmailIdentifier to_email_identifier(GLib.Variant serialised)
|
||||
throws EngineError.BAD_PARAMETERS {
|
||||
try {
|
||||
return object_or_throw_call(
|
||||
"to_email_identifier",
|
||||
{ box_arg(serialised) },
|
||||
new EngineError.BAD_PARAMETERS("Mock error")
|
||||
);
|
||||
} catch (EngineError.BAD_PARAMETERS err) {
|
||||
throw err;
|
||||
} catch (GLib.Error err) {
|
||||
return new MockEmailIdentifer(0);
|
||||
}
|
||||
}
|
||||
|
||||
public override Gee.Collection<Folder> list_folders() throws Error {
|
||||
return object_call<Gee.Collection<Folder>>(
|
||||
"list_folders", {}, Gee.List.empty<Folder>()
|
||||
|
|
|
|||
|
|
@ -21,4 +21,8 @@ public class Geary.MockEmailIdentifer : EmailIdentifier {
|
|||
return (other_mock == null) ? 1 : this.id - other_mock.id;
|
||||
}
|
||||
|
||||
public override GLib.Variant to_variant() {
|
||||
return new GLib.Variant.int32(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public class Geary.FolderPathTest : TestCase {
|
|||
add_test("path_compare", path_compare);
|
||||
add_test("path_compare_normalised", path_compare_normalised);
|
||||
add_test("distinct_roots_compare", distinct_roots_compare);
|
||||
add_test("variant_representation", variant_representation);
|
||||
}
|
||||
|
||||
public override void set_up() {
|
||||
|
|
@ -305,4 +306,12 @@ public class Geary.FolderPathTest : TestCase {
|
|||
|
||||
}
|
||||
|
||||
public void variant_representation() throws GLib.Error {
|
||||
FolderPath orig = this.root.get_child("test");
|
||||
GLib.Variant variant = orig.to_variant();
|
||||
FolderPath copy = this.root.from_variant(variant);
|
||||
|
||||
assert_true(orig.equal_to(copy));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
26
test/engine/imap-db/imap-db-email-identifier-test.vala
Normal file
26
test/engine/imap-db/imap-db-email-identifier-test.vala
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
public class Geary.ImapDB.EmailIdentifierTest : TestCase {
|
||||
|
||||
|
||||
public EmailIdentifierTest() {
|
||||
base("Geary.ImapDB.EmailIdentifierTest");
|
||||
add_test("variant_representation", variant_representation);
|
||||
}
|
||||
|
||||
public void variant_representation() throws GLib.Error {
|
||||
EmailIdentifier orig = new EmailIdentifier(
|
||||
123, new Imap.UID(321)
|
||||
);
|
||||
GLib.Variant variant = orig.to_variant();
|
||||
EmailIdentifier copy = new EmailIdentifier.from_variant(variant);
|
||||
|
||||
assert_true(orig.equal_to(copy));
|
||||
}
|
||||
|
||||
}
|
||||
24
test/engine/outbox/outbox-email-identifier-test.vala
Normal file
24
test/engine/outbox/outbox-email-identifier-test.vala
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
public class Geary.Outbox.EmailIdentifierTest : TestCase {
|
||||
|
||||
|
||||
public EmailIdentifierTest() {
|
||||
base("Geary.Outbox.EmailIdentifierTest");
|
||||
add_test("variant_representation", variant_representation);
|
||||
}
|
||||
|
||||
public void variant_representation() throws GLib.Error {
|
||||
EmailIdentifier orig = new EmailIdentifier(123, 321);
|
||||
GLib.Variant variant = orig.to_variant();
|
||||
EmailIdentifier copy = new EmailIdentifier.from_variant(variant);
|
||||
|
||||
assert_true(orig.equal_to(copy));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -40,9 +40,11 @@ geary_test_engine_sources = [
|
|||
'engine/imap-db/imap-db-account-test.vala',
|
||||
'engine/imap-db/imap-db-attachment-test.vala',
|
||||
'engine/imap-db/imap-db-database-test.vala',
|
||||
'engine/imap-db/imap-db-email-identifier-test.vala',
|
||||
'engine/imap-db/imap-db-folder-test.vala',
|
||||
'engine/imap-engine/account-processor-test.vala',
|
||||
'engine/mime-content-type-test.vala',
|
||||
'engine/outbox/outbox-email-identifier-test.vala',
|
||||
'engine/rfc822-mailbox-address-test.vala',
|
||||
'engine/rfc822-mailbox-addresses-test.vala',
|
||||
'engine/rfc822-message-test.vala',
|
||||
|
|
|
|||
|
|
@ -50,11 +50,13 @@ int main(string[] args) {
|
|||
engine.add_suite(new Geary.ImapDB.AttachmentTest().get_suite());
|
||||
engine.add_suite(new Geary.ImapDB.AttachmentIoTest().get_suite());
|
||||
engine.add_suite(new Geary.ImapDB.DatabaseTest().get_suite());
|
||||
engine.add_suite(new Geary.ImapDB.EmailIdentifierTest().get_suite());
|
||||
engine.add_suite(new Geary.ImapDB.FolderTest().get_suite());
|
||||
engine.add_suite(new Geary.ImapEngine.AccountProcessorTest().get_suite());
|
||||
engine.add_suite(new Geary.Inet.Test().get_suite());
|
||||
engine.add_suite(new Geary.JS.Test().get_suite());
|
||||
engine.add_suite(new Geary.Mime.ContentTypeTest().get_suite());
|
||||
engine.add_suite(new Geary.Outbox.EmailIdentifierTest().get_suite());
|
||||
engine.add_suite(new Geary.RFC822.MailboxAddressTest().get_suite());
|
||||
engine.add_suite(new Geary.RFC822.MailboxAddressesTest().get_suite());
|
||||
engine.add_suite(new Geary.RFC822.MessageTest().get_suite());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue