2016-12-12 22:47:53 +11:00
|
|
|
/*
|
2018-07-26 11:25:35 +10: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) {
|
2016-12-26 13:18:51 +10:30
|
|
|
/*
|
|
|
|
|
* Initialise all the things.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-07-02 14:32:07 +02:00
|
|
|
GLib.Intl.setlocale(LocaleCategory.ALL, "C.UTF-8");
|
2019-06-24 21:00:51 +10:00
|
|
|
|
|
|
|
|
Test.init(ref args);
|
2019-06-22 14:08:03 +10:00
|
|
|
|
Fix HTML, CSS and JS leaking into conversation list preview. Bug 714317
When generating the preview, only the first 128 bytes of the first MIME
part is fetched and used. If this part is text/html with a significant
amount of embedded CSS, then there is a good chance the string passed to
Geary.HTML::remove_html_tags() will be invalid, or be missing closing
elements. Since that function uses regexes that require balanced tags to
remove script and style blocks, then it was very possible that in these
cases this method will miss removing these blocks.
To solve this, remove_html_tags() is removed and its call sites are
replaced by calls to Geary.HTML::html_to_text(), which has been tidyied
up to produce more human-readable result.
Add unit tests to cover new html_to_text functionality and its call
sites.
* src/engine/util/util-html.vala: Remove remove_html_tags(). Update
html_to_text() to not just insert line breaks, but also insert spaces
and alt text, and ignore tags like HEAD, SCRIPT and STYLE, as
appropriate. Add an optional param to also allow skipping BLOCKQUOTE
elements, which we don't want in the preview.
2016-12-18 23:28:53 +11:00
|
|
|
Geary.RFC822.init();
|
|
|
|
|
Geary.HTML.init();
|
2017-01-01 12:37:08 +11:00
|
|
|
Geary.Logging.init();
|
2020-04-10 14:31:41 +10:00
|
|
|
if (GLib.Test.verbose()) {
|
|
|
|
|
GLib.Log.set_writer_func(Geary.Logging.default_log_writer);
|
|
|
|
|
Geary.Logging.log_to(GLib.stdout);
|
|
|
|
|
}
|
Fix HTML, CSS and JS leaking into conversation list preview. Bug 714317
When generating the preview, only the first 128 bytes of the first MIME
part is fetched and used. If this part is text/html with a significant
amount of embedded CSS, then there is a good chance the string passed to
Geary.HTML::remove_html_tags() will be invalid, or be missing closing
elements. Since that function uses regexes that require balanced tags to
remove script and style blocks, then it was very possible that in these
cases this method will miss removing these blocks.
To solve this, remove_html_tags() is removed and its call sites are
replaced by calls to Geary.HTML::html_to_text(), which has been tidyied
up to produce more human-readable result.
Add unit tests to cover new html_to_text functionality and its call
sites.
* src/engine/util/util-html.vala: Remove remove_html_tags(). Update
html_to_text() to not just insert line breaks, but also insert spaces
and alt text, and ignore tags like HEAD, SCRIPT and STYLE, as
appropriate. Add an optional param to also allow skipping BLOCKQUOTE
elements, which we don't want in the preview.
2016-12-18 23:28:53 +11:00
|
|
|
|
2016-12-26 13:18:51 +10:30
|
|
|
/*
|
|
|
|
|
* Hook up all tests into appropriate suites
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
TestSuite engine = new TestSuite("engine");
|
2016-12-12 23:39:46 +11:00
|
|
|
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.AccountInformationTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.AttachmentTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.ContactHarvesterImplTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.EngineTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.FolderPathTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.IdleManagerTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.TimeoutManagerTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.TlsNegotiationMethodTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.App.ConversationTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.App.ConversationSetTest().steal_suite());
|
2018-04-04 15:58:44 +10:00
|
|
|
// Depends on ConversationTest and ConversationSetTest passing
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.App.ConversationMonitorTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Ascii.Test().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.ConfigFileTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Db.DatabaseTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Db.VersionedDatabaseTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.HTML.UtilTest().steal_suite());
|
2019-12-29 01:56:48 +10:30
|
|
|
|
|
|
|
|
// Other IMAP tests rely on these working, so test them first
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.Imap.DataFormatTest().steal_suite());
|
2019-12-29 01:56:48 +10:30
|
|
|
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.Imap.CreateCommandTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Imap.FetchCommandTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Imap.FetchDataDecoderTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Imap.ListParameterTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Imap.MailboxSpecifierTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Imap.NamespaceResponseTest().steal_suite());
|
2019-12-29 01:56:48 +10:30
|
|
|
|
|
|
|
|
// Depends on IMAP commands working
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.Imap.DeserializerTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Imap.ClientConnectionTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Imap.ClientSessionTest().steal_suite());
|
2019-12-29 01:56:48 +10:30
|
|
|
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.ImapDB.AccountTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.ImapDB.AttachmentTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.ImapDB.AttachmentIoTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.ImapDB.DatabaseTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.ImapDB.EmailIdentifierTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.ImapDB.FolderTest().steal_suite());
|
2020-11-05 00:21:39 +11:00
|
|
|
|
|
|
|
|
// Depends on ImapDB working
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.FtsSearchQueryTest().steal_suite());
|
2019-12-29 01:56:48 +10:30
|
|
|
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.ImapEngine.AccountProcessorTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.ImapEngine.GenericAccountTest().steal_suite());
|
2019-06-09 21:56:25 +10:00
|
|
|
|
|
|
|
|
// Depends on ImapDb.Database working correctly
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.ContactStoreImplTest().steal_suite());
|
|
|
|
|
|
|
|
|
|
engine.add_suite(new Geary.Inet.Test().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Mime.ContentTypeTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.Outbox.EmailIdentifierTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.RFC822.MailboxAddressTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.RFC822.MailboxAddressesTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.RFC822.MessageDataTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.RFC822.PartTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.RFC822.Utils.Test().steal_suite());
|
2020-05-06 12:23:18 +10:00
|
|
|
// Message requires all of the rest of the package working, so put
|
|
|
|
|
// last
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
engine.add_suite(new Geary.RFC822.MessageTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.String.Test().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.EmailTest().steal_suite());
|
|
|
|
|
engine.add_suite(new Geary.ComposedEmailTest().steal_suite());
|
2016-12-26 13:18:51 +10:30
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Run the tests
|
|
|
|
|
*/
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
unowned TestSuite root = TestSuite.get_root();
|
|
|
|
|
root.add_suite((owned) engine);
|
2017-11-23 09:35:51 +11:00
|
|
|
|
|
|
|
|
MainLoop loop = new MainLoop ();
|
2016-12-12 23:39:46 +11:00
|
|
|
|
2016-12-31 14:49:38 +11:00
|
|
|
int ret = -1;
|
|
|
|
|
Idle.add(() => {
|
|
|
|
|
ret = Test.run();
|
2017-11-23 09:35:51 +11:00
|
|
|
loop.quit();
|
2016-12-31 14:49:38 +11:00
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
2017-11-23 09:35:51 +11:00
|
|
|
loop.run();
|
2016-12-31 14:49:38 +11:00
|
|
|
return ret;
|
2016-12-12 22:47:53 +11:00
|
|
|
}
|