Update existing tests to work with ValaUnit
This commit is contained in:
parent
6b1bad28b9
commit
0ae633d88f
53 changed files with 773 additions and 756 deletions
|
|
@ -88,39 +88,35 @@ class Geary.AccountInformationTest : TestCase {
|
|||
|
||||
public void test_service_label() throws GLib.Error {
|
||||
AccountInformation test = new_information();
|
||||
assert_string("", test.service_label);
|
||||
assert_equal(test.service_label, "");
|
||||
|
||||
test = new_information();
|
||||
test.incoming.host = "example.com";
|
||||
assert_string(
|
||||
"example.com", test.service_label, "Email domain equals host name"
|
||||
);
|
||||
assert_equal(test.service_label, "example.com");
|
||||
|
||||
test = new_information();
|
||||
test.incoming.host = "test.example.com";
|
||||
assert_string(
|
||||
"example.com", test.service_label, "Email domain host name suffix"
|
||||
);
|
||||
assert_equal(test.service_label, "example.com");
|
||||
|
||||
test = new_information();
|
||||
test.incoming.host = "other.com";
|
||||
test.outgoing.host = "other.com";
|
||||
assert_string("other.com", test.service_label);
|
||||
assert_equal(test.service_label, "other.com");
|
||||
|
||||
test = new_information();
|
||||
test.incoming.host = "mail.other.com";
|
||||
test.outgoing.host = "mail.other.com";
|
||||
assert_string("other.com", test.service_label);
|
||||
assert_equal(test.service_label, "other.com");
|
||||
|
||||
test = new_information();
|
||||
test.incoming.host = "imap.other.com";
|
||||
test.outgoing.host = "smtp.other.com";
|
||||
assert_string("other.com", test.service_label);
|
||||
assert_equal(test.service_label, "other.com");
|
||||
|
||||
test = new_information();
|
||||
test.incoming.host = "not-mail.other.com";
|
||||
test.outgoing.host = "not-mail.other.com";
|
||||
assert_string("other.com", test.service_label);
|
||||
assert_equal(test.service_label, "other.com");
|
||||
}
|
||||
|
||||
private AccountInformation new_information(ServiceProvider provider =
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
public class Geary.MockAccount : Account, MockObject {
|
||||
public class Geary.MockAccount : Account,
|
||||
ValaUnit.TestAssertions,
|
||||
ValaUnit.MockObject {
|
||||
|
||||
|
||||
public class MockSearchQuery : SearchQuery {
|
||||
|
|
@ -47,8 +49,8 @@ public class Geary.MockAccount : Account, MockObject {
|
|||
}
|
||||
|
||||
|
||||
protected Gee.Queue<ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ExpectedCall>();
|
||||
protected Gee.Queue<ValaUnit.ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ValaUnit.ExpectedCall>();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,17 +59,13 @@ class Geary.AttachmentTest : TestCase {
|
|||
get_safe_file_name_with_unknown_content_type);
|
||||
}
|
||||
|
||||
public override void set_up() {
|
||||
try {
|
||||
this.content_type = Mime.ContentType.parse(CONTENT_TYPE);
|
||||
this.default_type = Mime.ContentType.ATTACHMENT_DEFAULT;
|
||||
this.content_disposition = new Mime.ContentDisposition("attachment", null);
|
||||
public override void set_up() throws GLib.Error {
|
||||
this.content_type = Mime.ContentType.parse(CONTENT_TYPE);
|
||||
this.default_type = Mime.ContentType.ATTACHMENT_DEFAULT;
|
||||
this.content_disposition = new Mime.ContentDisposition("attachment", null);
|
||||
|
||||
File source = File.new_for_path(_SOURCE_ROOT_DIR);
|
||||
this.file = source.get_child(FILE_PATH);
|
||||
} catch (Error err) {
|
||||
assert_not_reached();
|
||||
}
|
||||
File source = File.new_for_path(_SOURCE_ROOT_DIR);
|
||||
this.file = source.get_child(FILE_PATH);
|
||||
}
|
||||
|
||||
public void get_safe_file_name_with_content_name() throws Error {
|
||||
|
|
@ -219,7 +215,7 @@ class Geary.AttachmentTest : TestCase {
|
|||
|
||||
test.get_safe_file_name.begin(null, this.async_completion);
|
||||
|
||||
assert_string(TEST_FILENAME, test.get_safe_file_name.end(async_result()));
|
||||
assert_equal(test.get_safe_file_name.end(async_result()), TEST_FILENAME);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
internal class Geary.ContactStoreMock : ContactStore, MockObject, GLib.Object {
|
||||
internal class Geary.ContactStoreMock : GLib.Object,
|
||||
ContactStore, ValaUnit.TestAssertions, ValaUnit.MockObject {
|
||||
|
||||
protected Gee.Queue<ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ExpectedCall>();
|
||||
protected Gee.Queue<ValaUnit.ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ValaUnit.ExpectedCall>();
|
||||
}
|
||||
|
||||
public async Contact? get_by_rfc822(Geary.RFC822.MailboxAddress address,
|
||||
|
|
|
|||
|
|
@ -6,11 +6,14 @@
|
|||
*/
|
||||
|
||||
public class Geary.MockCredentialsMediator :
|
||||
GLib.Object, CredentialsMediator, MockObject {
|
||||
GLib.Object,
|
||||
CredentialsMediator,
|
||||
ValaUnit.TestAssertions,
|
||||
ValaUnit.MockObject {
|
||||
|
||||
|
||||
protected Gee.Queue<ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ExpectedCall>();
|
||||
protected Gee.Queue<ValaUnit.ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ValaUnit.ExpectedCall>();
|
||||
}
|
||||
|
||||
public virtual async bool load_token(AccountInformation account,
|
||||
|
|
|
|||
|
|
@ -55,15 +55,11 @@ class Geary.EngineTest : TestCase {
|
|||
this.account.set_account_directories(this.tmp, this.tmp);
|
||||
}
|
||||
|
||||
public override void tear_down () {
|
||||
public override void tear_down() throws GLib.Error {
|
||||
this.account = null;
|
||||
try {
|
||||
this.res.delete();
|
||||
this.tmp.delete();
|
||||
this.tmp = null;
|
||||
} catch (Error err) {
|
||||
assert_not_reached();
|
||||
}
|
||||
this.res.delete();
|
||||
this.tmp.delete();
|
||||
this.tmp = null;
|
||||
}
|
||||
|
||||
public void add_account() throws GLib.Error {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
public class Geary.MockFolder : Folder, MockObject {
|
||||
public class Geary.MockFolder : Folder,
|
||||
ValaUnit.TestAssertions,
|
||||
ValaUnit.MockObject {
|
||||
|
||||
|
||||
public override Account account {
|
||||
|
|
@ -28,8 +30,8 @@ public class Geary.MockFolder : Folder, MockObject {
|
|||
get { return this._opening_monitor; }
|
||||
}
|
||||
|
||||
protected Gee.Queue<ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ExpectedCall>();
|
||||
protected Gee.Queue<ValaUnit.ExpectedCall> expected {
|
||||
get; set; default = new Gee.LinkedList<ValaUnit.ExpectedCall>();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -41,16 +41,12 @@ public class Geary.FolderPathTest : TestCase {
|
|||
}
|
||||
|
||||
public void get_child_from_root() throws GLib.Error {
|
||||
assert_string(
|
||||
"test",
|
||||
this.root.get_child("test").name
|
||||
);
|
||||
assert_equal(this.root.get_child("test").name, "test");
|
||||
}
|
||||
|
||||
public void get_child_from_child() throws GLib.Error {
|
||||
assert_string(
|
||||
"test2",
|
||||
this.root.get_child("test1").get_child("test2").name
|
||||
assert_equal(
|
||||
this.root.get_child("test1").get_child("test2").name, "test2"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -63,32 +59,20 @@ public class Geary.FolderPathTest : TestCase {
|
|||
}
|
||||
|
||||
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"
|
||||
);
|
||||
assert_array(
|
||||
this.root.as_array(),
|
||||
"Root list"
|
||||
).size(0);
|
||||
|
||||
assert_array(
|
||||
this.root.get_child("test").as_array(),
|
||||
"Child array"
|
||||
).size(1).contains("test");
|
||||
|
||||
assert_array(
|
||||
this.root.get_child("test1").get_child("test2").as_array(),
|
||||
"Descendent array"
|
||||
).size(2).first_is("test1").at_index_is(1, "test2");
|
||||
}
|
||||
|
||||
public void is_top_level() throws GLib.Error {
|
||||
|
|
@ -115,24 +99,25 @@ public class Geary.FolderPathTest : TestCase {
|
|||
}
|
||||
|
||||
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()
|
||||
assert_equal(this.root.to_string(), ">");
|
||||
assert_equal(this.root.get_child("test").to_string(), ">test");
|
||||
assert_equal(
|
||||
this.root.get_child("test1").get_child("test2").to_string(),
|
||||
">test1>test2"
|
||||
);
|
||||
}
|
||||
|
||||
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",
|
||||
"Root child parent"
|
||||
).is_empty();
|
||||
assert_equal(
|
||||
this.root.get_child("test1").get_child("test2").parent.name,
|
||||
"Child parent");
|
||||
"test1",
|
||||
"Child parent"
|
||||
);
|
||||
}
|
||||
|
||||
public void path_equal() throws GLib.Error {
|
||||
|
|
@ -170,138 +155,148 @@ public class Geary.FolderPathTest : TestCase {
|
|||
}
|
||||
|
||||
public void path_compare() throws GLib.Error {
|
||||
assert_int(0, this.root.compare_to(this.root), "Root equality");
|
||||
assert_int(0,
|
||||
// / == /
|
||||
assert_compare_eq(this.root.compare_to(this.root), "Root equality");
|
||||
// /a == /a
|
||||
assert_compare_eq(
|
||||
this.root.get_child("a").compare_to(this.root.get_child("a")),
|
||||
"Equal child comparison"
|
||||
);
|
||||
|
||||
// a is less than b
|
||||
assert_true(
|
||||
this.root.get_child("a").compare_to(this.root.get_child("b")) < 0,
|
||||
"Greater than child comparison"
|
||||
);
|
||||
|
||||
// b is greater than than a
|
||||
assert_true(
|
||||
this.root.get_child("b").compare_to(this.root.get_child("a")) > 0,
|
||||
// /a < /b
|
||||
assert_compare_lt(
|
||||
this.root.get_child("a").compare_to(this.root.get_child("b")),
|
||||
"Less than child comparison"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
this.root.get_child("a").get_child("test")
|
||||
.compare_to(this.root.get_child("a")) > 0,
|
||||
"Greater than descendant"
|
||||
// /b > /a
|
||||
assert_compare_gt(
|
||||
this.root.get_child("b").compare_to(this.root.get_child("a")),
|
||||
"Greater than child comparison"
|
||||
);
|
||||
assert_true(
|
||||
|
||||
// /a < /a/test
|
||||
assert_compare_lt(
|
||||
this.root.get_child("a")
|
||||
.compare_to(this.root.get_child("a").get_child("test")) < 0,
|
||||
.compare_to(this.root.get_child("a").get_child("test")),
|
||||
"Less than descendant"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
// /a/test > /a
|
||||
assert_compare_gt(
|
||||
this.root.get_child("a").get_child("test")
|
||||
.compare_to(this.root.get_child("a")),
|
||||
"Greater than descendant"
|
||||
);
|
||||
|
||||
// /a/b == /a/b
|
||||
assert_compare_eq(
|
||||
this.root.get_child("a").get_child("b")
|
||||
.compare_to(this.root.get_child("a").get_child("b")) == 0,
|
||||
.compare_to(this.root.get_child("a").get_child("b")),
|
||||
"N-path equality"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
// /a/test < /b/test
|
||||
assert_compare_lt(
|
||||
this.root.get_child("a").get_child("test")
|
||||
.compare_to(this.root.get_child("b").get_child("test")) < 0,
|
||||
"Greater than disjoint paths"
|
||||
);
|
||||
assert_true(
|
||||
this.root.get_child("b").get_child("test")
|
||||
.compare_to(this.root.get_child("a").get_child("test")) > 0,
|
||||
.compare_to(this.root.get_child("b").get_child("test")),
|
||||
"Less than disjoint paths"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
this.root.get_child("a").get_child("d")
|
||||
.compare_to(this.root.get_child("b").get_child("c")) < 0,
|
||||
"Greater than double disjoint"
|
||||
// /b/test > /a/test
|
||||
assert_compare_gt(
|
||||
this.root.get_child("b").get_child("test")
|
||||
.compare_to(this.root.get_child("a").get_child("test")),
|
||||
"Greater than disjoint paths"
|
||||
);
|
||||
assert_true(
|
||||
|
||||
// /a/d < /b/c
|
||||
assert_compare_lt(
|
||||
this.root.get_child("a").get_child("d")
|
||||
.compare_to(this.root.get_child("b").get_child("c")),
|
||||
"Less than double disjoint"
|
||||
);
|
||||
|
||||
// /b/c > /a/d
|
||||
assert_compare_gt(
|
||||
this.root.get_child("b").get_child("c")
|
||||
.compare_to(this.root.get_child("a").get_child("d")) > 0,
|
||||
.compare_to(this.root.get_child("a").get_child("d")),
|
||||
"Less than double disjoint"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public void path_compare_normalised() throws GLib.Error {
|
||||
assert_int(0, this.root.compare_normalized_ci(this.root), "Root equality");
|
||||
assert_int(0,
|
||||
assert_compare_eq(
|
||||
this.root.compare_normalized_ci(this.root), "Root equality"
|
||||
);
|
||||
assert_compare_eq(
|
||||
this.root.get_child("a").compare_normalized_ci(this.root.get_child("a")),
|
||||
"Equal child comparison"
|
||||
);
|
||||
|
||||
// a is less than b
|
||||
assert_true(
|
||||
this.root.get_child("a").compare_normalized_ci(this.root.get_child("b")) < 0,
|
||||
assert_compare_lt(
|
||||
this.root.get_child("a").compare_normalized_ci(this.root.get_child("b")),
|
||||
"Greater than child comparison"
|
||||
);
|
||||
|
||||
// b is greater than than a
|
||||
assert_true(
|
||||
this.root.get_child("b").compare_normalized_ci(this.root.get_child("a")) > 0,
|
||||
assert_compare_gt(
|
||||
this.root.get_child("b").compare_normalized_ci(this.root.get_child("a")),
|
||||
"Less than child comparison"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
assert_compare_lt(
|
||||
this.root.get_child("a").get_child("test")
|
||||
.compare_normalized_ci(this.root.get_child("b").get_child("test")) < 0,
|
||||
.compare_normalized_ci(this.root.get_child("b").get_child("test")),
|
||||
"Greater than disjoint parents"
|
||||
);
|
||||
assert_true(
|
||||
assert_compare_gt(
|
||||
this.root.get_child("b").get_child("test")
|
||||
.compare_normalized_ci(this.root.get_child("a").get_child("test")) > 0,
|
||||
.compare_normalized_ci(this.root.get_child("a").get_child("test")),
|
||||
"Less than disjoint parents"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
assert_compare_gt(
|
||||
this.root.get_child("a").get_child("test")
|
||||
.compare_normalized_ci(this.root.get_child("a")) > 0,
|
||||
.compare_normalized_ci(this.root.get_child("a")),
|
||||
"Greater than descendant"
|
||||
);
|
||||
assert_true(
|
||||
assert_compare_lt(
|
||||
this.root.get_child("a")
|
||||
.compare_normalized_ci(this.root.get_child("a").get_child("test")) < 0,
|
||||
.compare_normalized_ci(this.root.get_child("a").get_child("test")),
|
||||
"Less than descendant"
|
||||
);
|
||||
}
|
||||
|
||||
public void root_instances_compare() throws GLib.Error {
|
||||
assert_int(
|
||||
0, this.root.compare_to(new FolderRoot(TEST_LABEL, false)),
|
||||
assert_compare_eq(
|
||||
this.root.compare_to(new FolderRoot(TEST_LABEL, false)),
|
||||
"Root equality"
|
||||
);
|
||||
assert_int(
|
||||
0, this.root.get_child("a").compare_to(new FolderRoot(TEST_LABEL, false).get_child("a")),
|
||||
assert_compare_eq(
|
||||
this.root.get_child("a").compare_to(new FolderRoot(TEST_LABEL, false).get_child("a")),
|
||||
"Equal child comparison"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
assert_compare_gt(
|
||||
this.root.get_child("a").compare_to(
|
||||
new FolderRoot("#other", false).get_child("a")) > 0,
|
||||
new FolderRoot("#other", false).get_child("a")),
|
||||
"Root label inequality with children"
|
||||
);
|
||||
|
||||
// a is less than b
|
||||
assert_true(
|
||||
this.root.get_child("a").compare_to(new FolderRoot(TEST_LABEL, false).get_child("b")) < 0,
|
||||
assert_compare_lt(
|
||||
this.root.get_child("a").compare_to(new FolderRoot(TEST_LABEL, false).get_child("b")),
|
||||
"Greater than child comparison"
|
||||
);
|
||||
|
||||
// b is greater than than a
|
||||
assert_true(
|
||||
this.root.get_child("b").compare_to(new FolderRoot(TEST_LABEL, false).get_child("a")) > 0,
|
||||
assert_compare_gt(
|
||||
this.root.get_child("b").compare_to(new FolderRoot(TEST_LABEL, false).get_child("a")),
|
||||
"Less than child comparison"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
assert_compare_gt(
|
||||
this.root.get_child("a").get_child("test")
|
||||
.compare_to(new FolderRoot(TEST_LABEL, false).get_child("a")) > 0,
|
||||
.compare_to(new FolderRoot(TEST_LABEL, false).get_child("a")),
|
||||
"Greater than descendant"
|
||||
);
|
||||
assert_true(
|
||||
|
|
@ -310,20 +305,20 @@ public class Geary.FolderPathTest : TestCase {
|
|||
"Less than descendant"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
assert_compare_eq(
|
||||
this.root.get_child("a").get_child("b")
|
||||
.compare_to(new FolderRoot(TEST_LABEL, false).get_child("a").get_child("b")) == 0,
|
||||
.compare_to(new FolderRoot(TEST_LABEL, false).get_child("a").get_child("b")),
|
||||
"N-path equality"
|
||||
);
|
||||
|
||||
assert_true(
|
||||
assert_compare_lt(
|
||||
this.root.get_child("a").get_child("a")
|
||||
.compare_to(new FolderRoot(TEST_LABEL, false).get_child("b").get_child("b")) < 0,
|
||||
.compare_to(new FolderRoot(TEST_LABEL, false).get_child("b").get_child("b")),
|
||||
"Less than double disjoint"
|
||||
);
|
||||
assert_true(
|
||||
assert_compare_gt(
|
||||
this.root.get_child("b").get_child("a")
|
||||
.compare_to(new FolderRoot(TEST_LABEL, false).get_child("a").get_child("a")) > 0,
|
||||
.compare_to(new FolderRoot(TEST_LABEL, false).get_child("a").get_child("a")),
|
||||
"Greater than double disjoint"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,18 +15,18 @@ class Geary.TlsNegotiationMethodTest : TestCase {
|
|||
}
|
||||
|
||||
public void to_value() throws GLib.Error {
|
||||
assert_string("start-tls", TlsNegotiationMethod.START_TLS.to_value());
|
||||
assert_equal(TlsNegotiationMethod.START_TLS.to_value(), "start-tls");
|
||||
}
|
||||
|
||||
public void for_value() throws GLib.Error {
|
||||
assert_int(
|
||||
TlsNegotiationMethod.START_TLS,
|
||||
TlsNegotiationMethod.for_value("start-tls"),
|
||||
assert_equal(
|
||||
TlsNegotiationMethod.for_value("start-tls").to_string(),
|
||||
TlsNegotiationMethod.START_TLS.to_string(),
|
||||
"start-tls"
|
||||
);
|
||||
assert_int(
|
||||
TlsNegotiationMethod.START_TLS,
|
||||
TlsNegotiationMethod.for_value("Start-TLS"),
|
||||
assert_equal(
|
||||
TlsNegotiationMethod.for_value("Start-TLS").to_string(),
|
||||
TlsNegotiationMethod.START_TLS.to_string(),
|
||||
"Start-TLS"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue