Geary.Account.Information: Fix special use folder not correctly stored

The special use map needs custom hash and equality functions to
work correctly. Add these and some unit tests.

See #995
This commit is contained in:
Michael Gratton 2020-08-30 18:26:26 +10:00
parent d8d59cd565
commit 39f687fcd3
2 changed files with 28 additions and 1 deletions

View file

@ -13,6 +13,7 @@ class Geary.AccountInformationTest : TestCase {
add_test("test_save_sent_defaults", test_save_sent_defaults);
add_test("test_sender_mailboxes", test_sender_mailboxes);
add_test("test_service_label", test_service_label);
add_test("folder_steps_accessors", folder_steps_accessors);
}
public void test_save_sent_defaults() throws GLib.Error {
@ -119,6 +120,29 @@ class Geary.AccountInformationTest : TestCase {
assert_equal(test.service_label, "other.com");
}
public void folder_steps_accessors() throws GLib.Error {
AccountInformation test = new_information();
assert_collection(test.get_folder_steps_for_use(NONE)).is_empty();
assert_collection(test.get_folder_steps_for_use(ARCHIVE)).is_empty();
assert_collection(test.get_folder_steps_for_use(JUNK)).is_empty();
var archive = new Gee.ArrayList<string>.wrap({"Archive"});
test.set_folder_steps_for_use(ARCHIVE, archive);
assert_collection(test.get_folder_steps_for_use(ARCHIVE))
.is_non_empty()
.contains("Archive");
var junk = new Gee.ArrayList<string>.wrap({"Junk"});
test.set_folder_steps_for_use(JUNK, junk);
assert_collection(test.get_folder_steps_for_use(ARCHIVE))
.is_non_empty()
.contains("Archive");
assert_collection(test.get_folder_steps_for_use(JUNK))
.is_non_empty()
.contains("Junk");
}
private AccountInformation new_information(ServiceProvider provider =
ServiceProvider.OTHER) {
return new AccountInformation(