geary/test/test-engine.vala

79 lines
3.1 KiB
Vala
Raw Normal View History

2016-12-12 22:47:53 +11:00
/*
* Copyright 2016-2018 Michael Gratton <mike@vee.net>
2016-12-12 22:47:53 +11:00
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
2016-12-12 23:39:46 +11:00
int main(string[] args) {
/*
* Initialise all the things.
*/
2016-12-12 22:47:53 +11:00
Test.init(ref args);
Geary.RFC822.init();
Geary.HTML.init();
Geary.Logging.init();
/*
* Hook up all tests into appropriate suites
*/
TestSuite engine = new TestSuite("engine");
2016-12-12 23:39:46 +11:00
engine.add_suite(new Geary.AccountInformationTest().get_suite());
engine.add_suite(new Geary.AttachmentTest().get_suite());
engine.add_suite(new Geary.EngineTest().get_suite());
engine.add_suite(new Geary.IdleManagerTest().get_suite());
engine.add_suite(new Geary.TimeoutManagerTest().get_suite());
engine.add_suite(new Geary.App.ConversationTest().get_suite());
engine.add_suite(new Geary.App.ConversationSetTest().get_suite());
// Depends on ConversationTest and ConversationSetTest passing
engine.add_suite(new Geary.App.ConversationMonitorTest().get_suite());
engine.add_suite(new Geary.Ascii.Test().get_suite());
engine.add_suite(new Geary.ConfigFileTest().get_suite());
Make database classes more amenable to asynchronous use. This makes both the open() and open_connection() methods on Geary.DB.Database asynchronous, which allows the VersionedDatabase open_background() and its hackery to be removed, and upgrades to be performed asynchronously as well. It also adds a exec_transaction_async() method to Connection, allowing an existing object to also be used to establish an async transaction. * src/engine/db/db-connection.vala (Connection): Add exec_transaction_async method, update doc comments. * src/engine/db/db-database.vala (Database): Make open and open_connection async by executing SQLite code in a background thread, update call sites. Move job management code out of exec_transaction_async into a new internal add_async_job() method so it can be used by Connection. Add unit tests. * src/engine/db/db-transaction-async-job.vala (TransactionAsyncJob): Add an optional internal connection method and make the job's cancellable an internal property so a Connection instance can specify itself for the transaction. * src/engine/db/db-versioned-database.vala (VersionedDatabase): Remove open_background() hack since open() is now async. Make version upgrade hooks for derived classes async and update call sites. Use a Nonblocking.Mutex rather than GLib mutex so upgrade exclusion works asynchronously. Add unit tests. * src/engine/imap-db/imap-db-database.vala (Database): Make database upgrade methods async and execute SQL in async instructions now that the bases classes support it. Add unit tests.
2018-05-08 09:18:06 +09:30
engine.add_suite(new Geary.Db.DatabaseTest().get_suite());
engine.add_suite(new Geary.Db.VersionedDatabaseTest().get_suite());
engine.add_suite(new Geary.HTML.UtilTest().get_suite());
// Other IMAP tests rely on DataFormat working, so test that first
engine.add_suite(new Geary.Imap.DataFormatTest().get_suite());
engine.add_suite(new Geary.Imap.CreateCommandTest().get_suite());
engine.add_suite(new Geary.Imap.DeserializerTest().get_suite());
engine.add_suite(new Geary.Imap.FetchCommandTest().get_suite());
engine.add_suite(new Geary.Imap.ListParameterTest().get_suite());
engine.add_suite(new Geary.Imap.MailboxSpecifierTest().get_suite());
engine.add_suite(new Geary.Imap.NamespaceResponseTest().get_suite());
engine.add_suite(new Geary.ImapDB.AttachmentTest().get_suite());
engine.add_suite(new Geary.ImapDB.AttachmentIoTest().get_suite());
Make database classes more amenable to asynchronous use. This makes both the open() and open_connection() methods on Geary.DB.Database asynchronous, which allows the VersionedDatabase open_background() and its hackery to be removed, and upgrades to be performed asynchronously as well. It also adds a exec_transaction_async() method to Connection, allowing an existing object to also be used to establish an async transaction. * src/engine/db/db-connection.vala (Connection): Add exec_transaction_async method, update doc comments. * src/engine/db/db-database.vala (Database): Make open and open_connection async by executing SQLite code in a background thread, update call sites. Move job management code out of exec_transaction_async into a new internal add_async_job() method so it can be used by Connection. Add unit tests. * src/engine/db/db-transaction-async-job.vala (TransactionAsyncJob): Add an optional internal connection method and make the job's cancellable an internal property so a Connection instance can specify itself for the transaction. * src/engine/db/db-versioned-database.vala (VersionedDatabase): Remove open_background() hack since open() is now async. Make version upgrade hooks for derived classes async and update call sites. Use a Nonblocking.Mutex rather than GLib mutex so upgrade exclusion works asynchronously. Add unit tests. * src/engine/imap-db/imap-db-database.vala (Database): Make database upgrade methods async and execute SQL in async instructions now that the bases classes support it. Add unit tests.
2018-05-08 09:18:06 +09:30
engine.add_suite(new Geary.ImapDB.DatabaseTest().get_suite());
engine.add_suite(new Geary.ImapEngine.AccountProcessorTest().get_suite());
engine.add_suite(new Geary.Inet.Test().get_suite());
engine.add_suite(new Geary.JS.Test().get_suite());
engine.add_suite(new Geary.Mime.ContentTypeTest().get_suite());
engine.add_suite(new Geary.RFC822.MailboxAddressTest().get_suite());
engine.add_suite(new Geary.RFC822.MailboxAddressesTest().get_suite());
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.String.Test().get_suite());
/*
* Run the tests
*/
TestSuite root = TestSuite.get_root();
root.add_suite(engine);
MainLoop loop = new MainLoop ();
2016-12-12 23:39:46 +11:00
int ret = -1;
Idle.add(() => {
ret = Test.run();
loop.quit();
return false;
});
loop.run();
return ret;
2016-12-12 22:47:53 +11:00
}