Clean up Geary.Engine account API and implementation
Keep a single ordered list of accounts around, construct accounts when their config is first added, and prefer accessing accounts by config rather than id.
This commit is contained in:
parent
93d1ab684b
commit
ecfd772c07
5 changed files with 200 additions and 186 deletions
|
|
@ -58,6 +58,7 @@ class Geary.EngineTest : TestCase {
|
|||
new MockCredentialsMediator(),
|
||||
new RFC822.MailboxAddress(null, "test1@example.com")
|
||||
);
|
||||
this.account.set_account_directories(this.tmp, this.tmp);
|
||||
}
|
||||
|
||||
public override void tear_down () {
|
||||
|
|
@ -72,10 +73,10 @@ class Geary.EngineTest : TestCase {
|
|||
}
|
||||
|
||||
public void add_account() throws GLib.Error {
|
||||
assert_false(this.engine.has_account(this.account.id));
|
||||
assert_false(this.engine.has_account(this.account));
|
||||
|
||||
this.engine.add_account(this.account);
|
||||
assert_true(this.engine.has_account(this.account.id), "Account not added");
|
||||
assert_true(this.engine.has_account(this.account), "Account not added");
|
||||
|
||||
try {
|
||||
this.engine.add_account(this.account);
|
||||
|
|
@ -87,23 +88,27 @@ class Geary.EngineTest : TestCase {
|
|||
|
||||
public void remove_account() throws GLib.Error {
|
||||
this.engine.add_account(this.account);
|
||||
assert_true(this.engine.has_account(this.account.id));
|
||||
assert_true(this.engine.has_account(this.account));
|
||||
|
||||
this.engine.remove_account(this.account);
|
||||
assert_false(this.engine.has_account(this.account.id), "Account not rmoeved");
|
||||
assert_false(this.engine.has_account(this.account), "Account not removed");
|
||||
|
||||
// Should not throw an error
|
||||
this.engine.remove_account(this.account);
|
||||
try {
|
||||
this.engine.remove_account(this.account);
|
||||
assert_not_reached();
|
||||
} catch (GLib.Error err) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void re_add_account() throws GLib.Error {
|
||||
assert_false(this.engine.has_account(this.account.id));
|
||||
assert_false(this.engine.has_account(this.account));
|
||||
|
||||
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));
|
||||
assert_true(this.engine.has_account(this.account));
|
||||
}
|
||||
|
||||
private void delete(File parent) throws Error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue