Merge branch 'master' into buzzert/deleted_flags
* master: (212 commits) Import standard GNOME Flatpak CI config rather than copy/pasting it Update Gitlab CI Flatpak build with standard template Fix build with new FolderPath API Only collapse runs of space, tab, carriage return, and newline Do not add non openable folders entry in sidemenu. Bug 712902 Reducing padding in conversation viewer list Fix build warnings Fix possible critical when removing an account is removed Fix local accounts for special-case providers not configured correctly Rework GenericAccount::ensure_special_folder_asyc yet again Add some useful debugging to GenericAcount Fix ambiguous test in AccountInformation.set_special_folder Fix pathological FolderPath.is_equal() case, add unit test Revamp Geary.FolderPath implementation Add additional FolderPath unit tests Convert Geary.FolderRoot to be an actual root, not just a top-level Stop duplicate inboxes being created, not being listed Ensure MinimalFolder remote open forces closed on hard errors Ensure accounts don't accidentially create multiple inbox-type folders Remove unwanted debuging cruft ...
This commit is contained in:
commit
30e9e8950b
199 changed files with 24708 additions and 13624 deletions
|
|
@ -10,32 +10,41 @@ class Geary.AccountInformationTest : TestCase {
|
|||
|
||||
public AccountInformationTest() {
|
||||
base("Geary.AccountInformationTest");
|
||||
add_test("has_email_address", has_email_address);
|
||||
add_test("test_sender_mailboxes", test_sender_mailboxes);
|
||||
}
|
||||
|
||||
public void has_email_address() throws GLib.Error {
|
||||
public void test_sender_mailboxes() throws GLib.Error {
|
||||
AccountInformation test = new AccountInformation(
|
||||
"test", new MockServiceInformation(), new MockServiceInformation()
|
||||
"test",
|
||||
ServiceProvider.OTHER,
|
||||
new MockCredentialsMediator(),
|
||||
new RFC822.MailboxAddress(null, "test1@example.com")
|
||||
);
|
||||
|
||||
test.primary_mailbox = (new RFC822.MailboxAddress(null, "test1@example.com"));
|
||||
test.add_alternate_mailbox(new RFC822.MailboxAddress(null, "test2@example.com"));
|
||||
test.add_alternate_mailbox(new RFC822.MailboxAddress(null, "test3@example.com"));
|
||||
assert_true(test.primary_mailbox.equal_to(
|
||||
new RFC822.MailboxAddress(null, "test1@example.com")));
|
||||
assert_false(test.has_sender_aliases);
|
||||
|
||||
test.append_sender(new RFC822.MailboxAddress(null, "test2@example.com"));
|
||||
assert_true(test.has_sender_aliases);
|
||||
|
||||
test.append_sender(new RFC822.MailboxAddress(null, "test3@example.com"));
|
||||
assert_true(test.has_sender_aliases);
|
||||
|
||||
assert_true(
|
||||
test.has_email_address(new RFC822.MailboxAddress(null, "test1@example.com")),
|
||||
test.has_sender_mailbox(new RFC822.MailboxAddress(null, "test1@example.com")),
|
||||
"Primary address not found"
|
||||
);
|
||||
assert_true(
|
||||
test.has_email_address(new RFC822.MailboxAddress(null, "test2@example.com")),
|
||||
test.has_sender_mailbox(new RFC822.MailboxAddress(null, "test2@example.com")),
|
||||
"First alt address not found"
|
||||
);
|
||||
assert_true(
|
||||
test.has_email_address(new RFC822.MailboxAddress(null, "test3@example.com")),
|
||||
test.has_sender_mailbox(new RFC822.MailboxAddress(null, "test3@example.com")),
|
||||
"Second alt address not found"
|
||||
);
|
||||
assert_false(
|
||||
test.has_email_address(new RFC822.MailboxAddress(null, "unknowne@example.com")),
|
||||
test.has_sender_mailbox(new RFC822.MailboxAddress(null, "unknowne@example.com")),
|
||||
"Unknown address found"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class Geary.MockAccount : Account, MockObject {
|
|||
public class MockContactStore : ContactStore {
|
||||
|
||||
internal MockContactStore() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override async void
|
||||
|
|
@ -31,13 +31,63 @@ public class Geary.MockAccount : Account, MockObject {
|
|||
}
|
||||
|
||||
|
||||
public class MockClientService : ClientService {
|
||||
|
||||
public MockClientService(AccountInformation account,
|
||||
ServiceInformation configuration,
|
||||
Endpoint remote) {
|
||||
base(account, configuration, remote);
|
||||
}
|
||||
|
||||
public override async void start(GLib.Cancellable? cancellable = null)
|
||||
throws GLib.Error {
|
||||
throw new EngineError.UNSUPPORTED("Mock method");
|
||||
}
|
||||
|
||||
public override async void stop(GLib.Cancellable? cancellable = null)
|
||||
throws GLib.Error {
|
||||
throw new EngineError.UNSUPPORTED("Mock method");
|
||||
}
|
||||
|
||||
public override void became_reachable() {
|
||||
|
||||
}
|
||||
|
||||
public override void became_unreachable() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected Gee.Queue<ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ExpectedCall>();
|
||||
}
|
||||
|
||||
|
||||
public MockAccount(string name, AccountInformation information) {
|
||||
base(name, information);
|
||||
public MockAccount(AccountInformation config) {
|
||||
base(config,
|
||||
new MockClientService(
|
||||
config,
|
||||
config.incoming,
|
||||
new Endpoint(
|
||||
new GLib.NetworkAddress(
|
||||
config.incoming.host, config.incoming.port
|
||||
),
|
||||
0, 0
|
||||
)
|
||||
),
|
||||
new MockClientService(
|
||||
config,
|
||||
config.outgoing,
|
||||
new Endpoint(
|
||||
new GLib.NetworkAddress(
|
||||
config.outgoing.host, config.outgoing.port
|
||||
),
|
||||
0, 0
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public override async void open_async(Cancellable? cancellable = null) throws Error {
|
||||
|
|
@ -60,21 +110,14 @@ public class Geary.MockAccount : Account, MockObject {
|
|||
void_call("rebuild_async", { cancellable });
|
||||
}
|
||||
|
||||
public override async void start_outgoing_client()
|
||||
throws Error {
|
||||
void_call("start_outgoing_client", {});
|
||||
}
|
||||
|
||||
public override async void start_incoming_client()
|
||||
throws Error {
|
||||
void_call("start_incoming_client", {});
|
||||
}
|
||||
|
||||
public override Gee.Collection<Folder> list_matching_folders(FolderPath? parent)
|
||||
throws Error {
|
||||
return object_call<Gee.Collection<Folder>>(
|
||||
"get_containing_folders_async", {parent}, Gee.List.empty<Folder>()
|
||||
);
|
||||
public override Gee.Collection<Folder> list_matching_folders(FolderPath? parent) {
|
||||
try {
|
||||
return object_call<Gee.Collection<Folder>>(
|
||||
"get_containing_folders_async", {parent}, Gee.List.empty<Folder>()
|
||||
);
|
||||
} catch (GLib.Error err) {
|
||||
return Gee.Collection.empty<Folder>();
|
||||
}
|
||||
}
|
||||
|
||||
public override Gee.Collection<Folder> list_folders() throws Error {
|
||||
|
|
|
|||
|
|
@ -11,12 +11,14 @@ class Geary.EngineTest : TestCase {
|
|||
private Engine? engine = null;
|
||||
private File? tmp = null;
|
||||
private File? res = null;
|
||||
private Geary.AccountInformation? account = null;
|
||||
|
||||
|
||||
public EngineTest() {
|
||||
base("Geary.EngineTest");
|
||||
add_test("create_orphan_account", create_orphan_account);
|
||||
add_test("create_orphan_account_with_legacy", create_orphan_account_with_legacy);
|
||||
add_test("add_account", add_account);
|
||||
add_test("remove_account", remove_account);
|
||||
add_test("re_add_account", re_add_account);
|
||||
}
|
||||
|
||||
~EngineTest() {
|
||||
|
|
@ -49,9 +51,17 @@ class Geary.EngineTest : TestCase {
|
|||
async_complete(res);
|
||||
});
|
||||
this.engine.open_async.end(async_result());
|
||||
|
||||
this.account = new AccountInformation(
|
||||
"test",
|
||||
ServiceProvider.OTHER,
|
||||
new MockCredentialsMediator(),
|
||||
new RFC822.MailboxAddress(null, "test1@example.com")
|
||||
);
|
||||
}
|
||||
|
||||
public override void tear_down () {
|
||||
this.account = null;
|
||||
try {
|
||||
this.res.delete();
|
||||
this.tmp.delete();
|
||||
|
|
@ -61,78 +71,42 @@ class Geary.EngineTest : TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void create_orphan_account() throws Error {
|
||||
public void add_account() throws GLib.Error {
|
||||
assert_false(this.engine.has_account(this.account.id));
|
||||
|
||||
this.engine.add_account(this.account);
|
||||
assert_true(this.engine.has_account(this.account.id), "Account not added");
|
||||
|
||||
try {
|
||||
AccountInformation info = this.engine.create_orphan_account(
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
);
|
||||
assert(info.id == "account_01");
|
||||
this.engine.add_account(info);
|
||||
|
||||
info = this.engine.create_orphan_account(
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
);
|
||||
assert(info.id == "account_02");
|
||||
this.engine.add_account(info);
|
||||
|
||||
info = this.engine.create_orphan_account(
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
);
|
||||
assert(info.id == "account_03");
|
||||
this.engine.add_account(info);
|
||||
|
||||
info = this.engine.create_orphan_account(
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
);
|
||||
assert(info.id == "account_04");
|
||||
} catch (Error err) {
|
||||
print("\nerr: %s\n", err.message);
|
||||
this.engine.add_account(this.account);
|
||||
assert_not_reached();
|
||||
} catch (GLib.Error err) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void create_orphan_account_with_legacy() throws Error {
|
||||
this.engine.add_account(
|
||||
new AccountInformation(
|
||||
"foo",
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
)
|
||||
);
|
||||
public void remove_account() throws GLib.Error {
|
||||
this.engine.add_account(this.account);
|
||||
assert_true(this.engine.has_account(this.account.id));
|
||||
|
||||
AccountInformation info = this.engine.create_orphan_account(
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
);
|
||||
assert(info.id == "account_01");
|
||||
this.engine.add_account(info);
|
||||
this.engine.remove_account(this.account);
|
||||
assert_false(this.engine.has_account(this.account.id), "Account not rmoeved");
|
||||
|
||||
info = this.engine.create_orphan_account(
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
);
|
||||
assert(info.id == "account_02");
|
||||
|
||||
this.engine.add_account(
|
||||
new AccountInformation(
|
||||
"bar",
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
)
|
||||
);
|
||||
|
||||
info = this.engine.create_orphan_account(
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
);
|
||||
assert(info.id == "account_02");
|
||||
// Should not throw an error
|
||||
this.engine.remove_account(this.account);
|
||||
}
|
||||
|
||||
private void delete(File parent) throws Error {
|
||||
public void re_add_account() throws GLib.Error {
|
||||
assert_false(this.engine.has_account(this.account.id));
|
||||
|
||||
this.engine.add_account(this.account);
|
||||
this.engine.remove_account(this.account);
|
||||
this.engine.add_account(this.account);
|
||||
|
||||
assert_true(this.engine.has_account(this.account.id));
|
||||
}
|
||||
|
||||
private void delete(File parent) throws Error {
|
||||
FileInfo info = parent.query_info(
|
||||
"standard::*",
|
||||
FileQueryInfoFlags.NOFOLLOW_SYMLINKS
|
||||
|
|
|
|||
|
|
@ -66,11 +66,6 @@ public class Geary.MockFolder : Folder, MockObject {
|
|||
);
|
||||
}
|
||||
|
||||
public override async void wait_for_remote_async(Cancellable? cancellable = null)
|
||||
throws Error {
|
||||
throw new EngineError.UNSUPPORTED("Mock method");
|
||||
}
|
||||
|
||||
public override async bool close_async(Cancellable? cancellable = null)
|
||||
throws Error {
|
||||
return boolean_call(
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public class Geary.MockFolderRoot : FolderRoot {
|
||||
|
||||
public MockFolderRoot(string name) {
|
||||
base(name, false, false);
|
||||
}
|
||||
|
||||
}
|
||||
249
test/engine/api/geary-folder-path-test.vala
Normal file
249
test/engine/api/geary-folder-path-test.vala
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
* 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.FolderPathTest : TestCase {
|
||||
|
||||
|
||||
private FolderRoot? root = null;
|
||||
|
||||
|
||||
public FolderPathTest() {
|
||||
base("Geary.FolderPathTest");
|
||||
add_test("get_child_from_root", get_child_from_root);
|
||||
add_test("get_child_from_child", get_child_from_child);
|
||||
add_test("root_is_root", root_is_root);
|
||||
add_test("child_is_not_root", root_is_root);
|
||||
add_test("as_array", as_array);
|
||||
add_test("is_top_level", is_top_level);
|
||||
add_test("path_to_string", path_to_string);
|
||||
add_test("path_parent", path_parent);
|
||||
add_test("path_equal", path_equal);
|
||||
add_test("path_hash", path_hash);
|
||||
add_test("path_compare", path_compare);
|
||||
add_test("path_compare_normalised", path_compare_normalised);
|
||||
}
|
||||
|
||||
public override void set_up() {
|
||||
this.root = new FolderRoot(false);
|
||||
}
|
||||
|
||||
public override void tear_down() {
|
||||
this.root = null;
|
||||
}
|
||||
|
||||
public void get_child_from_root() throws GLib.Error {
|
||||
assert_string(
|
||||
"test",
|
||||
this.root.get_child("test").name
|
||||
);
|
||||
}
|
||||
|
||||
public void get_child_from_child() throws GLib.Error {
|
||||
assert_string(
|
||||
"test2",
|
||||
this.root.get_child("test1").get_child("test2").name
|
||||
);
|
||||
}
|
||||
|
||||
public void root_is_root() throws GLib.Error {
|
||||
assert_true(this.root.is_root);
|
||||
}
|
||||
|
||||
public void child_root_is_not_root() throws GLib.Error {
|
||||
assert_false(this.root.get_child("test").is_root);
|
||||
}
|
||||
|
||||
public void as_array() throws GLib.Error {
|
||||
assert_true(this.root.as_array().length == 0, "Root list");
|
||||
assert_int(
|
||||
1,
|
||||
this.root.get_child("test").as_array().length,
|
||||
"Child array length"
|
||||
);
|
||||
assert_string(
|
||||
"test",
|
||||
this.root.get_child("test").as_array()[0],
|
||||
"Child array contents"
|
||||
);
|
||||
assert_int(
|
||||
2,
|
||||
this.root.get_child("test1").get_child("test2").as_array().length,
|
||||
"Descendent array length"
|
||||
);
|
||||
assert_string(
|
||||
"test1",
|
||||
this.root.get_child("test1").get_child("test2").as_array()[0],
|
||||
"Descendent first child"
|
||||
);
|
||||
assert_string(
|
||||
"test2",
|
||||
this.root.get_child("test1").get_child("test2").as_array()[1],
|
||||
"Descendent second child"
|
||||
);
|
||||
}
|
||||
|
||||
public void is_top_level() throws GLib.Error {
|
||||
assert_false(this.root.is_top_level, "Root is top_level");
|
||||
assert_true(
|
||||
this.root.get_child("test").is_top_level,
|
||||
"Top level is top_level"
|
||||
);
|
||||
assert_false(
|
||||
this.root.get_child("test").get_child("test").is_top_level,
|
||||
"Descendent is top_level"
|
||||
);
|
||||
}
|
||||
|
||||
public void path_to_string() throws GLib.Error {
|
||||
assert_string(">", this.root.to_string());
|
||||
assert_string(">test", this.root.get_child("test").to_string());
|
||||
assert_string(
|
||||
">test1>test2",
|
||||
this.root.get_child("test1").get_child("test2").to_string()
|
||||
);
|
||||
}
|
||||
|
||||
public void path_parent() throws GLib.Error {
|
||||
assert_null(this.root.parent, "Root parent");
|
||||
assert_string(
|
||||
"",
|
||||
this.root.get_child("test").parent.name,
|
||||
"Root child parent");
|
||||
assert_string(
|
||||
"test1",
|
||||
this.root.get_child("test1").get_child("test2").parent.name,
|
||||
"Child parent");
|
||||
}
|
||||
|
||||
public void path_equal() throws GLib.Error {
|
||||
assert_true(this.root.equal_to(this.root), "Root equality");
|
||||
assert_true(
|
||||
this.root.get_child("test").equal_to(this.root.get_child("test")),
|
||||
"Child equality"
|
||||
);
|
||||
assert_false(
|
||||
this.root.get_child("test1").equal_to(this.root.get_child("test2")),
|
||||
"Child names"
|
||||
);
|
||||
assert_false(
|
||||
this.root.get_child("test1").get_child("test")
|
||||
.equal_to(this.root.get_child("test2").get_child("test")),
|
||||
"Disjoint parents"
|
||||
);
|
||||
|
||||
assert_false(
|
||||
this.root.get_child("test").equal_to(
|
||||
this.root.get_child("").get_child("test")),
|
||||
"Pathological case"
|
||||
);
|
||||
}
|
||||
|
||||
public void path_hash() throws GLib.Error {
|
||||
assert_true(
|
||||
this.root.hash() !=
|
||||
this.root.get_child("test").hash()
|
||||
);
|
||||
assert_true(
|
||||
this.root.get_child("test1").hash() !=
|
||||
this.root.get_child("test2").hash()
|
||||
);
|
||||
}
|
||||
|
||||
public void path_compare() throws GLib.Error {
|
||||
assert_int(0, this.root.compare_to(this.root), "Root equality");
|
||||
assert_int(0,
|
||||
this.root.get_child("test").compare_to(this.root.get_child("test")),
|
||||
"Equal child comparison"
|
||||
);
|
||||
|
||||
assert_int(
|
||||
-1,
|
||||
this.root.get_child("test1").compare_to(this.root.get_child("test2")),
|
||||
"Greater than child comparison"
|
||||
);
|
||||
assert_int(
|
||||
1,
|
||||
this.root.get_child("test2").compare_to(this.root.get_child("test1")),
|
||||
"Less than child comparison"
|
||||
);
|
||||
|
||||
assert_int(
|
||||
-1,
|
||||
this.root.get_child("test1").get_child("test")
|
||||
.compare_to(this.root.get_child("test2").get_child("test")),
|
||||
"Greater than disjoint parents"
|
||||
);
|
||||
assert_int(
|
||||
1,
|
||||
this.root.get_child("test2").get_child("test")
|
||||
.compare_to(this.root.get_child("test1").get_child("test")),
|
||||
"Less than disjoint parents"
|
||||
);
|
||||
|
||||
assert_int(
|
||||
1,
|
||||
this.root.get_child("test1").get_child("test")
|
||||
.compare_to(this.root.get_child("test1")),
|
||||
"Greater than descendant"
|
||||
);
|
||||
assert_int(
|
||||
-1,
|
||||
this.root.get_child("test1")
|
||||
.compare_to(this.root.get_child("test1").get_child("test")),
|
||||
"Less than descendant"
|
||||
);
|
||||
}
|
||||
|
||||
public void path_compare_normalised() throws GLib.Error {
|
||||
assert_int(0, this.root.compare_normalized_ci(this.root), "Root equality");
|
||||
assert_int(0,
|
||||
this.root.get_child("test")
|
||||
.compare_normalized_ci(this.root.get_child("test")),
|
||||
"Equal child comparison"
|
||||
);
|
||||
|
||||
assert_int(
|
||||
-1,
|
||||
this.root.get_child("test1")
|
||||
.compare_normalized_ci(this.root.get_child("test2")),
|
||||
"Greater than child comparison"
|
||||
);
|
||||
assert_int(
|
||||
1,
|
||||
this.root.get_child("test2")
|
||||
.compare_normalized_ci(this.root.get_child("test1")),
|
||||
"Less than child comparison"
|
||||
);
|
||||
|
||||
assert_int(
|
||||
-1,
|
||||
this.root.get_child("test1").get_child("test")
|
||||
.compare_normalized_ci(this.root.get_child("test2").get_child("test")),
|
||||
"Greater than disjoint parents"
|
||||
);
|
||||
assert_int(
|
||||
1,
|
||||
this.root.get_child("test2").get_child("test")
|
||||
.compare_normalized_ci(this.root.get_child("test1").get_child("test")),
|
||||
"Less than disjoint parents"
|
||||
);
|
||||
|
||||
assert_int(
|
||||
1,
|
||||
this.root.get_child("test1").get_child("test")
|
||||
.compare_normalized_ci(this.root.get_child("test1")),
|
||||
"Greater than descendant"
|
||||
);
|
||||
assert_int(
|
||||
-1,
|
||||
this.root.get_child("test1")
|
||||
.compare_normalized_ci(this.root.get_child("test1").get_child("test")),
|
||||
"Less than descendant"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public class Geary.MockServiceInformation : ServiceInformation, MockObject {
|
||||
|
||||
|
||||
protected Gee.Queue<ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ExpectedCall>();
|
||||
}
|
||||
|
||||
public MockServiceInformation() {
|
||||
base(Protocol.IMAP, new MockCredentialsMediator());
|
||||
}
|
||||
|
||||
public override Geary.ServiceInformation temp_copy() {
|
||||
try {
|
||||
return object_call<Geary.ServiceInformation>(
|
||||
"temp_copy", { }, new MockServiceInformation()
|
||||
);
|
||||
} catch (GLib.Error err) {
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
34
test/engine/api/geary-service-information-test.vala
Normal file
34
test/engine/api/geary-service-information-test.vala
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2018 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.TlsNegotiationMethodTest : TestCase {
|
||||
|
||||
|
||||
public TlsNegotiationMethodTest() {
|
||||
base("Geary.TlsNegotiationMethodTest");
|
||||
add_test("to_value", to_value);
|
||||
add_test("for_value", for_value);
|
||||
}
|
||||
|
||||
public void to_value() throws GLib.Error {
|
||||
assert_string("start-tls", TlsNegotiationMethod.START_TLS.to_value());
|
||||
}
|
||||
|
||||
public void for_value() throws GLib.Error {
|
||||
assert_int(
|
||||
TlsNegotiationMethod.START_TLS,
|
||||
TlsNegotiationMethod.for_value("start-tls"),
|
||||
"start-tls"
|
||||
);
|
||||
assert_int(
|
||||
TlsNegotiationMethod.START_TLS,
|
||||
TlsNegotiationMethod.for_value("Start-TLS"),
|
||||
"Start-TLS"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ class Geary.App.ConversationMonitorTest : TestCase {
|
|||
|
||||
AccountInformation? account_info = null;
|
||||
MockAccount? account = null;
|
||||
FolderRoot? folder_root = null;
|
||||
MockFolder? base_folder = null;
|
||||
MockFolder? other_folder = null;
|
||||
|
||||
|
|
@ -31,26 +32,36 @@ class Geary.App.ConversationMonitorTest : TestCase {
|
|||
public override void set_up() {
|
||||
this.account_info = new AccountInformation(
|
||||
"account_01",
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
ServiceProvider.OTHER,
|
||||
new MockCredentialsMediator(),
|
||||
new RFC822.MailboxAddress(null, "test1@example.com")
|
||||
);
|
||||
this.account = new MockAccount("test", this.account_info);
|
||||
this.account = new MockAccount(this.account_info);
|
||||
this.folder_root = new FolderRoot(false);
|
||||
this.base_folder = new MockFolder(
|
||||
this.account,
|
||||
null,
|
||||
new MockFolderRoot("base"),
|
||||
this.folder_root.get_child("base"),
|
||||
SpecialFolderType.NONE,
|
||||
null
|
||||
);
|
||||
this.other_folder = new MockFolder(
|
||||
this.account,
|
||||
null,
|
||||
new MockFolderRoot("other"),
|
||||
this.folder_root.get_child("other"),
|
||||
SpecialFolderType.NONE,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
public override void tear_down() {
|
||||
this.other_folder = null;
|
||||
this.base_folder = null;
|
||||
this.folder_root = null;
|
||||
this.account_info = null;
|
||||
this.account = null;
|
||||
}
|
||||
|
||||
public void start_stop_monitoring() throws Error {
|
||||
ConversationMonitor monitor = new ConversationMonitor(
|
||||
this.base_folder, Folder.OpenFlags.NONE, Email.Field.NONE, 10
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class Geary.App.ConversationSetTest : TestCase {
|
|||
|
||||
|
||||
ConversationSet? test = null;
|
||||
FolderRoot? folder_root = null;
|
||||
Folder? base_folder = null;
|
||||
|
||||
public ConversationSetTest() {
|
||||
|
|
@ -26,14 +27,21 @@ class Geary.App.ConversationSetTest : TestCase {
|
|||
}
|
||||
|
||||
public override void set_up() {
|
||||
this.test = new ConversationSet();
|
||||
this.folder_root = new FolderRoot(false);
|
||||
this.base_folder = new MockFolder(
|
||||
null,
|
||||
null,
|
||||
new MockFolderRoot("test"),
|
||||
this.folder_root.get_child("test"),
|
||||
SpecialFolderType.NONE,
|
||||
null
|
||||
);
|
||||
this.test = new ConversationSet();
|
||||
}
|
||||
|
||||
public override void tear_down() {
|
||||
this.test = null;
|
||||
this.folder_root = null;
|
||||
this.base_folder = null;
|
||||
}
|
||||
|
||||
public void add_all_basic() throws Error {
|
||||
|
|
@ -144,7 +152,7 @@ class Geary.App.ConversationSetTest : TestCase {
|
|||
Gee.MultiMap<Geary.EmailIdentifier, Geary.FolderPath> email_paths =
|
||||
new Gee.HashMultiMap<Geary.EmailIdentifier, Geary.FolderPath>();
|
||||
email_paths.set(e1.id, this.base_folder.path);
|
||||
email_paths.set(e2.id, new MockFolderRoot("other"));
|
||||
email_paths.set(e2.id, this.folder_root.get_child("other"));
|
||||
|
||||
Gee.Collection<Conversation>? added = null;
|
||||
Gee.MultiMap<Conversation,Email>? appended = null;
|
||||
|
|
@ -310,7 +318,7 @@ class Geary.App.ConversationSetTest : TestCase {
|
|||
|
||||
public void add_all_multi_path() throws Error {
|
||||
Email e1 = setup_email(1);
|
||||
MockFolderRoot other_path = new MockFolderRoot("other");
|
||||
FolderPath other_path = this.folder_root.get_child("other");
|
||||
|
||||
Gee.LinkedList<Email> emails = new Gee.LinkedList<Email>();
|
||||
emails.add(e1);
|
||||
|
|
@ -340,7 +348,7 @@ class Geary.App.ConversationSetTest : TestCase {
|
|||
Email e1 = setup_email(1);
|
||||
add_email_to_test_set(e1);
|
||||
|
||||
MockFolderRoot other_path = new MockFolderRoot("other");
|
||||
FolderPath other_path = this.folder_root.get_child("other");
|
||||
|
||||
Gee.LinkedList<Email> emails = new Gee.LinkedList<Email>();
|
||||
emails.add(e1);
|
||||
|
|
@ -426,7 +434,7 @@ class Geary.App.ConversationSetTest : TestCase {
|
|||
}
|
||||
|
||||
public void remove_all_remove_path() throws Error {
|
||||
MockFolderRoot other_path = new MockFolderRoot("other");
|
||||
FolderPath other_path = this.folder_root.get_child("other");
|
||||
Email e1 = setup_email(1);
|
||||
add_email_to_test_set(e1, other_path);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ class Geary.App.ConversationTest : TestCase {
|
|||
|
||||
Conversation? test = null;
|
||||
Folder? base_folder = null;
|
||||
FolderRoot? folder_root = null;
|
||||
|
||||
|
||||
public ConversationTest() {
|
||||
base("Geary.App.ConversationTest");
|
||||
|
|
@ -25,16 +27,23 @@ class Geary.App.ConversationTest : TestCase {
|
|||
}
|
||||
|
||||
public override void set_up() {
|
||||
this.folder_root = new FolderRoot(false);
|
||||
this.base_folder = new MockFolder(
|
||||
null,
|
||||
null,
|
||||
new MockFolderRoot("test"),
|
||||
this.folder_root.get_child("test"),
|
||||
SpecialFolderType.NONE,
|
||||
null
|
||||
);
|
||||
this.test = new Conversation(this.base_folder);
|
||||
}
|
||||
|
||||
public override void tear_down() {
|
||||
this.test = null;
|
||||
this.folder_root = null;
|
||||
this.base_folder = null;
|
||||
}
|
||||
|
||||
public void add_basic() throws Error {
|
||||
Geary.Email e1 = setup_email(1);
|
||||
Geary.Email e2 = setup_email(2);
|
||||
|
|
@ -79,8 +88,8 @@ class Geary.App.ConversationTest : TestCase {
|
|||
Geary.Email e2 = setup_email(2);
|
||||
this.test.add(e2, singleton(this.base_folder.path));
|
||||
|
||||
FolderRoot other_path = new MockFolderRoot("other");
|
||||
Gee.LinkedList<FolderRoot> other_paths = new Gee.LinkedList<FolderRoot>();
|
||||
FolderPath other_path = this.folder_root.get_child("other");
|
||||
Gee.LinkedList<FolderPath> other_paths = new Gee.LinkedList<FolderPath>();
|
||||
other_paths.add(other_path);
|
||||
|
||||
assert(this.test.add(e1, other_paths) == false);
|
||||
|
|
@ -146,7 +155,7 @@ class Geary.App.ConversationTest : TestCase {
|
|||
Geary.Email e1 = setup_email(1);
|
||||
this.test.add(e1, singleton(this.base_folder.path));
|
||||
|
||||
FolderRoot other_path = new MockFolderRoot("other");
|
||||
FolderPath other_path = this.folder_root.get_child("other");
|
||||
Geary.Email e2 = setup_email(2);
|
||||
this.test.add(e2, singleton(other_path));
|
||||
|
||||
|
|
@ -159,7 +168,7 @@ class Geary.App.ConversationTest : TestCase {
|
|||
Geary.Email e1 = setup_email(1);
|
||||
this.test.add(e1, singleton(this.base_folder.path));
|
||||
|
||||
FolderRoot other_path = new MockFolderRoot("other");
|
||||
FolderPath other_path = this.folder_root.get_child("other");
|
||||
Geary.Email e2 = setup_email(2);
|
||||
this.test.add(e2, singleton(other_path));
|
||||
|
||||
|
|
@ -194,7 +203,7 @@ class Geary.App.ConversationTest : TestCase {
|
|||
Geary.Email e1 = setup_email(1);
|
||||
this.test.add(e1, singleton(this.base_folder.path));
|
||||
|
||||
FolderRoot other_path = new MockFolderRoot("other");
|
||||
FolderPath other_path = this.folder_root.get_child("other");
|
||||
Geary.Email e2 = setup_email(2);
|
||||
this.test.add(e2, singleton(other_path));
|
||||
|
||||
|
|
|
|||
309
test/engine/imap-db/imap-db-account-test.vala
Normal file
309
test/engine/imap-db/imap-db-account-test.vala
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
class Geary.ImapDB.AccountTest : TestCase {
|
||||
|
||||
|
||||
private GLib.File? tmp_dir = null;
|
||||
private Geary.AccountInformation? config = null;
|
||||
private Account? account = null;
|
||||
private FolderRoot? root = null;
|
||||
|
||||
|
||||
public AccountTest() {
|
||||
base("Geary.ImapDB.AccountTest");
|
||||
add_test("create_base_folder", create_base_folder);
|
||||
add_test("create_child_folder", create_child_folder);
|
||||
add_test("list_folders", list_folders);
|
||||
add_test("delete_folder", delete_folder);
|
||||
add_test("delete_folder_with_child", delete_folder_with_child);
|
||||
add_test("delete_nonexistent_folder", delete_nonexistent_folder);
|
||||
add_test("fetch_base_folder", fetch_base_folder);
|
||||
add_test("fetch_child_folder", fetch_child_folder);
|
||||
add_test("fetch_nonexistent_folder", fetch_nonexistent_folder);
|
||||
}
|
||||
|
||||
public override void set_up() throws GLib.Error {
|
||||
this.tmp_dir = GLib.File.new_for_path(
|
||||
GLib.DirUtils.make_tmp("geary-db-database-test-XXXXXX")
|
||||
);
|
||||
|
||||
this.config = new Geary.AccountInformation(
|
||||
"test",
|
||||
ServiceProvider.OTHER,
|
||||
new MockCredentialsMediator(),
|
||||
new Geary.RFC822.MailboxAddress(null, "test@example.com")
|
||||
);
|
||||
|
||||
this.account = new Account(config);
|
||||
this.account.open_async.begin(
|
||||
this.tmp_dir,
|
||||
GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql"),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
this.account.open_async.end(async_result());
|
||||
|
||||
this.root = new FolderRoot(false);
|
||||
}
|
||||
|
||||
public override void tear_down() throws GLib.Error {
|
||||
this.root = null;
|
||||
this.account.close_async.begin(
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
this.account.close_async.end(async_result());
|
||||
|
||||
delete_file(this.tmp_dir);
|
||||
this.tmp_dir = null;
|
||||
}
|
||||
|
||||
public void create_base_folder() throws GLib.Error {
|
||||
Imap.Folder folder = new Imap.Folder(
|
||||
this.root.get_child("test"),
|
||||
new Imap.FolderProperties.selectable(
|
||||
new Imap.MailboxAttributes(
|
||||
Gee.Collection.empty<Geary.Imap.MailboxAttribute>()
|
||||
),
|
||||
new Imap.StatusData(
|
||||
new Imap.MailboxSpecifier("test"),
|
||||
10, // total
|
||||
9, // recent
|
||||
new Imap.UID(8),
|
||||
new Imap.UIDValidity(7),
|
||||
6 //unseen
|
||||
),
|
||||
new Imap.Capabilities(1)
|
||||
)
|
||||
);
|
||||
|
||||
this.account.clone_folder_async.begin(
|
||||
folder,
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
this.account.clone_folder_async.end(async_result());
|
||||
|
||||
Geary.Db.Result result = this.account.db.query(
|
||||
"SELECT * FROM FolderTable;"
|
||||
);
|
||||
assert_false(result.finished, "Folder not created");
|
||||
assert_string("test", result.string_for("name"), "Folder name");
|
||||
assert_true(result.is_null_for("parent_id"), "Folder parent");
|
||||
assert_false(result.next(), "Multiple rows inserted");
|
||||
}
|
||||
|
||||
public void create_child_folder() throws GLib.Error {
|
||||
this.account.db.exec(
|
||||
"INSERT INTO FolderTable (id, name) VALUES (1, 'test');"
|
||||
);
|
||||
|
||||
Imap.Folder folder = new Imap.Folder(
|
||||
this.root.get_child("test").get_child("child"),
|
||||
new Imap.FolderProperties.selectable(
|
||||
new Imap.MailboxAttributes(
|
||||
Gee.Collection.empty<Geary.Imap.MailboxAttribute>()
|
||||
),
|
||||
new Imap.StatusData(
|
||||
new Imap.MailboxSpecifier("test>child"),
|
||||
10, // total
|
||||
9, // recent
|
||||
new Imap.UID(8),
|
||||
new Imap.UIDValidity(7),
|
||||
6 //unseen
|
||||
),
|
||||
new Imap.Capabilities(1)
|
||||
)
|
||||
);
|
||||
|
||||
this.account.clone_folder_async.begin(
|
||||
folder,
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
this.account.clone_folder_async.end(async_result());
|
||||
|
||||
Geary.Db.Result result = this.account.db.query(
|
||||
"SELECT * FROM FolderTable WHERE id != 1;"
|
||||
);
|
||||
assert_false(result.finished, "Folder not created");
|
||||
assert_string("child", result.string_for("name"), "Folder name");
|
||||
assert_int(1, result.int_for("parent_id"), "Folder parent");
|
||||
assert_false(result.next(), "Multiple rows inserted");
|
||||
}
|
||||
|
||||
public void list_folders() throws GLib.Error {
|
||||
this.account.db.exec("""
|
||||
INSERT INTO FolderTable (id, name, parent_id)
|
||||
VALUES
|
||||
(1, 'test1', null),
|
||||
(2, 'test2', 1),
|
||||
(3, 'test3', 2);
|
||||
""");
|
||||
|
||||
this.account.list_folders_async.begin(
|
||||
this.account.imap_folder_root,
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
Gee.Collection<Geary.ImapDB.Folder> result =
|
||||
this.account.list_folders_async.end(async_result());
|
||||
|
||||
Folder test1 = traverse(result).first();
|
||||
assert_int(1, result.size, "Base folder not listed");
|
||||
assert_string("test1", test1.get_path().name, "Base folder name");
|
||||
|
||||
this.account.list_folders_async.begin(
|
||||
test1.get_path(),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
result = this.account.list_folders_async.end(async_result());
|
||||
|
||||
Folder test2 = traverse(result).first();
|
||||
assert_int(1, result.size, "Child folder not listed");
|
||||
assert_string("test2", test2.get_path().name, "Child folder name");
|
||||
|
||||
this.account.list_folders_async.begin(
|
||||
test2.get_path(),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
result = this.account.list_folders_async.end(async_result());
|
||||
|
||||
Folder test3 = traverse(result).first();
|
||||
assert_int(1, result.size, "Grandchild folder not listed");
|
||||
assert_string("test3", test3.get_path().name, "Grandchild folder name");
|
||||
}
|
||||
|
||||
public void delete_folder() throws GLib.Error {
|
||||
this.account.db.exec("""
|
||||
INSERT INTO FolderTable (id, name, parent_id)
|
||||
VALUES
|
||||
(1, 'test1', null),
|
||||
(2, 'test2', 1);
|
||||
""");
|
||||
|
||||
this.account.delete_folder_async.begin(
|
||||
this.root.get_child("test1").get_child("test2"),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
this.account.delete_folder_async.end(async_result());
|
||||
|
||||
this.account.delete_folder_async.begin(
|
||||
this.root.get_child("test1"),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
this.account.delete_folder_async.end(async_result());
|
||||
}
|
||||
|
||||
public void delete_folder_with_child() throws GLib.Error {
|
||||
this.account.db.exec("""
|
||||
INSERT INTO FolderTable (id, name, parent_id)
|
||||
VALUES
|
||||
(1, 'test1', null),
|
||||
(2, 'test2', 1);
|
||||
""");
|
||||
|
||||
this.account.delete_folder_async.begin(
|
||||
this.root.get_child("test1"),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
try {
|
||||
this.account.delete_folder_async.end(async_result());
|
||||
assert_not_reached();
|
||||
} catch (GLib.Error err) {
|
||||
assert_error(new ImapError.NOT_SUPPORTED(""), err);
|
||||
}
|
||||
}
|
||||
|
||||
public void delete_nonexistent_folder() throws GLib.Error {
|
||||
this.account.db.exec("""
|
||||
INSERT INTO FolderTable (id, name, parent_id)
|
||||
VALUES
|
||||
(1, 'test1', null),
|
||||
(2, 'test2', 1);
|
||||
""");
|
||||
|
||||
this.account.delete_folder_async.begin(
|
||||
this.root.get_child("test3"),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
try {
|
||||
this.account.delete_folder_async.end(async_result());
|
||||
assert_not_reached();
|
||||
} catch (GLib.Error err) {
|
||||
assert_error(new EngineError.NOT_FOUND(""), err);
|
||||
}
|
||||
}
|
||||
|
||||
public void fetch_base_folder() throws GLib.Error {
|
||||
this.account.db.exec("""
|
||||
INSERT INTO FolderTable (id, name, parent_id)
|
||||
VALUES
|
||||
(1, 'test1', null),
|
||||
(2, 'test2', 1);
|
||||
""");
|
||||
|
||||
this.account.fetch_folder_async.begin(
|
||||
this.root.get_child("test1"),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
|
||||
Folder? result = this.account.fetch_folder_async.end(async_result());
|
||||
assert_non_null(result);
|
||||
assert_string("test1", result.get_path().name);
|
||||
}
|
||||
|
||||
public void fetch_child_folder() throws GLib.Error {
|
||||
this.account.db.exec("""
|
||||
INSERT INTO FolderTable (id, name, parent_id)
|
||||
VALUES
|
||||
(1, 'test1', null),
|
||||
(2, 'test2', 1);
|
||||
""");
|
||||
|
||||
this.account.fetch_folder_async.begin(
|
||||
this.root.get_child("test1").get_child("test2"),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
|
||||
Folder? result = this.account.fetch_folder_async.end(async_result());
|
||||
assert_non_null(result);
|
||||
assert_string("test2", result.get_path().name);
|
||||
}
|
||||
|
||||
public void fetch_nonexistent_folder() throws GLib.Error {
|
||||
this.account.db.exec("""
|
||||
INSERT INTO FolderTable (id, name, parent_id)
|
||||
VALUES
|
||||
(1, 'test1', null),
|
||||
(2, 'test2', 1);
|
||||
""");
|
||||
|
||||
this.account.fetch_folder_async.begin(
|
||||
this.root.get_child("test3"),
|
||||
null,
|
||||
(obj, ret) => { async_complete(ret); }
|
||||
);
|
||||
try {
|
||||
this.account.fetch_folder_async.end(async_result());
|
||||
assert_not_reached();
|
||||
} catch (GLib.Error err) {
|
||||
assert_error(new EngineError.NOT_FOUND(""), err);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -144,12 +144,11 @@ CREATE TABLE MessageAttachmentTable (
|
|||
this.db.close();
|
||||
this.db = null;
|
||||
|
||||
Geary.Files.recursive_delete_async.begin(
|
||||
this.tmp_dir,
|
||||
null,
|
||||
Files.recursive_delete_async.begin(
|
||||
this.tmp_dir, GLib.Priority.DEFAULT, null,
|
||||
(obj, res) => { async_complete(res); }
|
||||
);
|
||||
Geary.Files.recursive_delete_async.end(async_result());
|
||||
Files.recursive_delete_async.end(async_result());
|
||||
this.tmp_dir = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,11 +121,11 @@ class Geary.ImapDB.DatabaseTest : TestCase {
|
|||
// Need to close it again to stop the GC process running
|
||||
db.close();
|
||||
|
||||
Geary.Files.recursive_delete_async.begin(
|
||||
tmp_dir, null,
|
||||
Files.recursive_delete_async.begin(
|
||||
tmp_dir, GLib.Priority.DEFAULT, null,
|
||||
(obj, res) => { async_complete(res); }
|
||||
);
|
||||
Geary.Files.recursive_delete_async.end(async_result());
|
||||
Files.recursive_delete_async.end(async_result());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -71,10 +71,11 @@ public class Geary.ImapEngine.AccountProcessorTest : TestCase {
|
|||
public override void set_up() {
|
||||
this.info = new Geary.AccountInformation(
|
||||
"test-info",
|
||||
new MockServiceInformation(),
|
||||
new MockServiceInformation()
|
||||
ServiceProvider.OTHER,
|
||||
new MockCredentialsMediator(),
|
||||
new RFC822.MailboxAddress(null, "test1@example.com")
|
||||
);
|
||||
this.account = new Geary.MockAccount("test-account", this.info);
|
||||
this.account = new Geary.MockAccount(this.info);
|
||||
|
||||
this.succeeded = 0;
|
||||
this.failed = 0;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class Geary.Imap.MailboxSpecifierTest : TestCase {
|
|||
add_test("to_parameter", to_parameter);
|
||||
add_test("from_parameter", from_parameter);
|
||||
add_test("from_folder_path", from_folder_path);
|
||||
add_test("folder_path_is_inbox", folder_path_is_inbox);
|
||||
}
|
||||
|
||||
public void to_parameter() throws Error {
|
||||
|
|
@ -59,54 +60,82 @@ class Geary.Imap.MailboxSpecifierTest : TestCase {
|
|||
}
|
||||
|
||||
public void from_folder_path() throws Error {
|
||||
MockFolderRoot empty_root = new MockFolderRoot("");
|
||||
MailboxSpecifier empty_inbox = new MailboxSpecifier("Inbox");
|
||||
FolderRoot root = new FolderRoot();
|
||||
MailboxSpecifier inbox = new MailboxSpecifier("Inbox");
|
||||
assert_string(
|
||||
"Foo",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
empty_root.get_child("Foo"), empty_inbox, "$"
|
||||
root.get_child("Foo"), inbox, "$"
|
||||
).name
|
||||
);
|
||||
assert_string(
|
||||
"Foo$Bar",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
empty_root.get_child("Foo").get_child("Bar"), empty_inbox, "$"
|
||||
root.get_child("Foo").get_child("Bar"), inbox, "$"
|
||||
).name
|
||||
);
|
||||
assert_string(
|
||||
"Inbox",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
empty_root.get_child(MailboxSpecifier.CANONICAL_INBOX_NAME),
|
||||
empty_inbox,
|
||||
root.get_child(MailboxSpecifier.CANONICAL_INBOX_NAME),
|
||||
inbox,
|
||||
"$"
|
||||
).name
|
||||
);
|
||||
|
||||
MockFolderRoot non_empty_root = new MockFolderRoot("Root");
|
||||
MailboxSpecifier non_empty_inbox = new MailboxSpecifier("Inbox");
|
||||
assert_string(
|
||||
"Root$Foo",
|
||||
try {
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
non_empty_root.get_child("Foo"),
|
||||
non_empty_inbox,
|
||||
"$"
|
||||
).name
|
||||
root.get_child(""), inbox, "$"
|
||||
);
|
||||
assert_not_reached();
|
||||
} catch (GLib.Error err) {
|
||||
// all good
|
||||
}
|
||||
|
||||
try {
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
root.get_child("test").get_child(""), inbox, "$"
|
||||
);
|
||||
assert_not_reached();
|
||||
} catch (GLib.Error err) {
|
||||
// all good
|
||||
}
|
||||
|
||||
try {
|
||||
new MailboxSpecifier.from_folder_path(root, inbox, "$");
|
||||
assert_not_reached();
|
||||
} catch (GLib.Error err) {
|
||||
// all good
|
||||
}
|
||||
}
|
||||
|
||||
public void folder_path_is_inbox() throws GLib.Error {
|
||||
FolderRoot root = new FolderRoot();
|
||||
assert_true(
|
||||
MailboxSpecifier.folder_path_is_inbox(root.get_child("Inbox"))
|
||||
);
|
||||
assert_string(
|
||||
"Root$Foo$Bar",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
non_empty_root.get_child("Foo").get_child("Bar"),
|
||||
non_empty_inbox,
|
||||
"$"
|
||||
).name
|
||||
assert_true(
|
||||
MailboxSpecifier.folder_path_is_inbox(root.get_child("inbox"))
|
||||
);
|
||||
assert_string(
|
||||
"Root$INBOX",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
non_empty_root.get_child(MailboxSpecifier.CANONICAL_INBOX_NAME),
|
||||
non_empty_inbox,
|
||||
"$"
|
||||
).name
|
||||
assert_true(
|
||||
MailboxSpecifier.folder_path_is_inbox(root.get_child("INBOX"))
|
||||
);
|
||||
|
||||
assert_false(
|
||||
MailboxSpecifier.folder_path_is_inbox(root)
|
||||
);
|
||||
assert_false(
|
||||
MailboxSpecifier.folder_path_is_inbox(root.get_child("blah"))
|
||||
);
|
||||
assert_false(
|
||||
MailboxSpecifier.folder_path_is_inbox(
|
||||
root.get_child("blah").get_child("Inbox")
|
||||
)
|
||||
);
|
||||
assert_false(
|
||||
MailboxSpecifier.folder_path_is_inbox(
|
||||
root.get_child("Inbox").get_child("Inbox")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,15 @@ class Geary.ConfigFileTest : TestCase {
|
|||
base("Geary.ConfigFileTest");
|
||||
add_test("test_string", test_string);
|
||||
add_test("test_string_fallback", test_string_fallback);
|
||||
add_test("test_escaped_string", test_escaped_string);
|
||||
add_test("test_string_list", test_string_list);
|
||||
add_test("test_string_list", test_string_list);
|
||||
add_test("test_bool", test_bool);
|
||||
add_test("test_int", test_int);
|
||||
add_test("test_uint16", test_uint16);
|
||||
add_test("test_has_key", test_has_key);
|
||||
add_test("test_key_remove", test_key_remove);
|
||||
add_test("test_group_exists", test_group_exists);
|
||||
add_test("test_group_remove", test_group_remove);
|
||||
}
|
||||
|
||||
public override void set_up() throws GLib.Error {
|
||||
|
|
@ -51,12 +54,6 @@ class Geary.ConfigFileTest : TestCase {
|
|||
assert_string("a string", this.test_group.get_string(TEST_KEY));
|
||||
}
|
||||
|
||||
public void test_escaped_string() throws Error {
|
||||
this.test_group.set_escaped_string(TEST_KEY, "a\nstring");
|
||||
assert_string("a\nstring", this.test_group.get_escaped_string(TEST_KEY));
|
||||
assert_string("=default", this.test_group.get_escaped_string(TEST_KEY_MISSING, "=default"));
|
||||
}
|
||||
|
||||
public void test_string_list() throws Error {
|
||||
this.test_group.set_string_list(
|
||||
TEST_KEY, new Gee.ArrayList<string>.wrap({ "a", "b"})
|
||||
|
|
@ -90,5 +87,43 @@ class Geary.ConfigFileTest : TestCase {
|
|||
assert_int(42, this.test_group.get_uint16(TEST_KEY_MISSING, 42));
|
||||
}
|
||||
|
||||
public void test_has_key() throws Error {
|
||||
assert_false(
|
||||
this.test_group.has_key(TEST_KEY),
|
||||
"Should not already exist"
|
||||
);
|
||||
this.test_group.set_string(TEST_KEY, "a string");
|
||||
assert_true(
|
||||
this.test_group.has_key(TEST_KEY), "Should now exist"
|
||||
);
|
||||
}
|
||||
|
||||
public void test_key_remove() throws Error {
|
||||
// create the key
|
||||
this.test_group.set_string(TEST_KEY, "a string");
|
||||
assert_true(
|
||||
this.test_group.has_key(TEST_KEY), "Should exist"
|
||||
);
|
||||
|
||||
this.test_group.remove_key(TEST_KEY);
|
||||
assert_false(
|
||||
this.test_group.has_key(TEST_KEY), "Should no longer exist"
|
||||
);
|
||||
}
|
||||
|
||||
public void test_group_exists() throws Error {
|
||||
assert_false(this.test_group.exists, "Should not already exist");
|
||||
this.test_group.set_string(TEST_KEY, "a string");
|
||||
assert_true(this.test_group.exists, "Should now exist");
|
||||
}
|
||||
|
||||
public void test_group_remove() throws Error {
|
||||
// create the group
|
||||
this.test_group.set_string(TEST_KEY, "a string");
|
||||
assert_true(this.test_group.exists, "Should exist");
|
||||
|
||||
this.test_group.remove();
|
||||
assert_false(this.test_group.exists, "Should no longer exist");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue