[geary] Add ContentType.is_default and unit test.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Add ContentType.is_default and unit test.
- Date: Wed, 15 Feb 2017 22:23:16 +0000 (UTC)
commit 183da8bd3f5bab055482e2f1d05844252ea1e59f
Author: Michael James Gratton <mike vee net>
Date: Wed Feb 15 17:50:13 2017 +1100
Add ContentType.is_default and unit test.
src/engine/mime/mime-content-type.vala | 9 ++++++++-
test/engine/mime-content-type-test.vala | 4 ++++
2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/engine/mime/mime-content-type.vala b/src/engine/mime/mime-content-type.vala
index 6f7350b..59d530b 100644
--- a/src/engine/mime/mime-content-type.vala
+++ b/src/engine/mime/mime-content-type.vala
@@ -233,7 +233,14 @@ public class Geary.Mime.ContentType : Geary.BaseObject {
return is_type(mime_media_type, mime_media_subtype);
}
-
+
+ /**
+ * Determines if this type is the same as the default content type.
+ */
+ public bool is_default() {
+ return get_mime_type() == DEFAULT_CONTENT_TYPE;
+ }
+
public string serialize() {
StringBuilder builder = new StringBuilder();
builder.append_printf("%s/%s", media_type, media_subtype);
diff --git a/test/engine/mime-content-type-test.vala b/test/engine/mime-content-type-test.vala
index 6e4c418..951cffa 100644
--- a/test/engine/mime-content-type-test.vala
+++ b/test/engine/mime-content-type-test.vala
@@ -9,10 +9,14 @@ class Geary.Mime.ContentTypeTest : Gee.TestCase {
public ContentTypeTest() {
base("Geary.Mime.ContentTypeTest");
+ add_test("is_default", is_default);
add_test("get_file_name_extension", get_file_name_extension);
add_test("guess_type_from_name", guess_type_from_name);
add_test("guess_type_from_buf", guess_type_from_buf);
}
+
+ public void is_default() {
+ assert(new ContentType("application", "octet-stream", null).is_default());
}
public void get_file_name_extension() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]