[geary/wip/730682-refine-convo-list: 6/37] Add some useful Engine API mock objects.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/730682-refine-convo-list: 6/37] Add some useful Engine API mock objects.
- Date: Mon, 11 Dec 2017 21:13:06 +0000 (UTC)
commit a816469a8a7b09d0614e17870f179b679937965d
Author: Michael James Gratton <mike vee net>
Date: Wed Dec 6 16:23:31 2017 +1100
Add some useful Engine API mock objects.
test/CMakeLists.txt | 3 +
test/engine/api/geary-email-identifier-test.vala | 24 +++++
test/engine/api/geary-folder-path-test.vala | 14 +++
test/engine/api/geary-folder-test.vala | 119 ++++++++++++++++++++++
test/test-engine.vala | 4 +-
5 files changed, 162 insertions(+), 2 deletions(-)
---
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7affa70..fb39f5d 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -8,6 +8,9 @@ set(TEST_ENGINE_SRC
engine/api/geary-attachment-test.vala
engine/api/geary-engine-test.vala
+ engine/api/geary-email-identifier-test.vala
+ engine/api/geary-folder-test.vala
+ engine/api/geary-folder-path-test.vala
engine/imap/command/imap-create-command-test.vala
engine/imap/response/imap-namespace-response-test.vala
engine/imap/transport/imap-deserializer-test.vala
diff --git a/test/engine/api/geary-email-identifier-test.vala
b/test/engine/api/geary-email-identifier-test.vala
new file mode 100644
index 0000000..adda6ed
--- /dev/null
+++ b/test/engine/api/geary-email-identifier-test.vala
@@ -0,0 +1,24 @@
+/*
+ * 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.MockEmailIdentifer : EmailIdentifier {
+
+
+ private int id;
+
+
+ public MockEmailIdentifer(int id) {
+ base(id.to_string());
+ this.id = id;
+ }
+
+ public override int natural_sort_comparator(Geary.EmailIdentifier other) {
+ MockEmailIdentifer? other_mock = other as MockEmailIdentifer;
+ return (other_mock == null) ? -1 : other_mock.id - this.id;
+ }
+
+}
diff --git a/test/engine/api/geary-folder-path-test.vala b/test/engine/api/geary-folder-path-test.vala
new file mode 100644
index 0000000..c9048ae
--- /dev/null
+++ b/test/engine/api/geary-folder-path-test.vala
@@ -0,0 +1,14 @@
+/*
+ * 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);
+ }
+
+}
diff --git a/test/engine/api/geary-folder-test.vala b/test/engine/api/geary-folder-test.vala
new file mode 100644
index 0000000..718e491
--- /dev/null
+++ b/test/engine/api/geary-folder-test.vala
@@ -0,0 +1,119 @@
+/*
+ * 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.MockFolder : Folder {
+
+ public override Account account {
+ get { return this._account; }
+ }
+
+ public override FolderProperties properties {
+ get { return this._properties; }
+ }
+
+ public override FolderPath path {
+ get { return this._path; }
+ }
+
+ public override SpecialFolderType special_folder_type {
+ get { return this._type; }
+ }
+
+ public override ProgressMonitor opening_monitor {
+ get { return this._opening_monitor; }
+ }
+
+ private Account _account;
+ private FolderProperties _properties;
+ private FolderPath _path;
+ private SpecialFolderType _type;
+ private ProgressMonitor _opening_monitor;
+
+
+ public MockFolder(Account? account,
+ FolderProperties? properties,
+ FolderPath? path,
+ SpecialFolderType type,
+ ProgressMonitor? monitor) {
+ this._account = account;
+ this._properties = properties;
+ this._path = path;
+ this._type = type;
+ this._opening_monitor = monitor;
+ }
+
+ public override Folder.OpenState get_open_state() {
+ return OpenState.CLOSED;
+ }
+
+ public override async bool open_async(Folder.OpenFlags open_flags,
+ Cancellable? cancellable = null)
+ throws Error {
+ throw new EngineError.UNSUPPORTED("Mock method");
+ }
+
+ public override async void wait_for_open_async(Cancellable? cancellable = null)
+ throws Error {
+ throw new EngineError.UNSUPPORTED("Mock method");
+ }
+
+ public override async bool close_async(Cancellable? cancellable = null)
+ throws Error {
+ throw new EngineError.UNSUPPORTED("Mock method");
+ }
+
+ public override async void wait_for_close_async(Cancellable? cancellable = null)
+ throws Error {
+ throw new EngineError.UNSUPPORTED("Mock method");
+ }
+
+ public override async void
+ find_boundaries_async(Gee.Collection<Geary.EmailIdentifier> ids,
+ out Geary.EmailIdentifier? low,
+ out Geary.EmailIdentifier? high,
+ Cancellable? cancellable = null)
+ throws Error {
+ throw new EngineError.UNSUPPORTED("Mock method");
+ }
+
+
+ public override async Gee.List<Geary.Email>?
+ list_email_by_id_async(Geary.EmailIdentifier? initial_id,
+ int count,
+ Geary.Email.Field required_fields,
+ Folder.ListFlags flags,
+ Cancellable? cancellable = null)
+ throws Error {
+ throw new EngineError.UNSUPPORTED("Mock method");
+ }
+
+ public override async Gee.List<Geary.Email>?
+ list_email_by_sparse_id_async(Gee.Collection<Geary.EmailIdentifier> ids,
+ Geary.Email.Field required_fields,
+ Folder.ListFlags flags,
+ Cancellable? cancellable = null)
+ throws Error {
+ throw new EngineError.UNSUPPORTED("Mock method");
+ }
+
+ public override async Gee.Map<Geary.EmailIdentifier, Geary.Email.Field>?
+ list_local_email_fields_async(Gee.Collection<Geary.EmailIdentifier> ids,
+ Cancellable? cancellable = null)
+ throws Error {
+ throw new EngineError.UNSUPPORTED("Mock method");
+ }
+
+ public override async Geary.Email
+ fetch_email_async(Geary.EmailIdentifier email_id,
+ Geary.Email.Field required_fields,
+ Folder.ListFlags flags,
+ Cancellable? cancellable = null)
+ throws Error {
+ throw new EngineError.UNSUPPORTED("Mock method");
+ }
+
+}
diff --git a/test/test-engine.vala b/test/test-engine.vala
index b30c7a2..e01dfd2 100644
--- a/test/test-engine.vala
+++ b/test/test-engine.vala
@@ -24,8 +24,9 @@ int main(string[] args) {
engine.add_suite(new Geary.AttachmentTest().get_suite());
engine.add_suite(new Geary.EngineTest().get_suite());
- engine.add_suite(new Geary.HTML.UtilTest().get_suite());
engine.add_suite(new Geary.IdleManagerTest().get_suite());
+ engine.add_suite(new Geary.TimeoutManagerTest().get_suite());
+ engine.add_suite(new Geary.HTML.UtilTest().get_suite());
engine.add_suite(new Geary.Imap.DeserializerTest().get_suite());
engine.add_suite(new Geary.Imap.CreateCommandTest().get_suite());
engine.add_suite(new Geary.Imap.NamespaceResponseTest().get_suite());
@@ -36,7 +37,6 @@ int main(string[] args) {
engine.add_suite(new Geary.RFC822.MessageTest().get_suite());
engine.add_suite(new Geary.RFC822.MessageDataTest().get_suite());
engine.add_suite(new Geary.RFC822.Utils.Test().get_suite());
- engine.add_suite(new Geary.TimeoutManagerTest().get_suite());
/*
* Run the tests
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]