Commit graph

7 commits

Author SHA1 Message Date
Michael James Gratton
50120c67ff Add simple/demo client unit test using GSettings.
* test/client/application/geary-configuration-test.vala: New unit test
  for Configuration class.

* test/main.vala: Add new unit test to the client suite, ensure the
  memory GSettings backend is used as the default so we get default
  setting values, and never save any changes made.

* test/CMakeLists.txt: Add new unit test source.

* src/client/application/geary-config.vala: Tidy up code a bit to adhere
  to code conventions.
2016-12-26 13:21:58 +10:30
Michael James Gratton
325232bad7 Add client lib to the test build.
* test/CMakeLists.txt: Add client lib and dependent packages to the
  build.

* test/main.vala (main): Add test suites  for both client and engine
  tests to allow some more fine-grained control when running them. Also
  add some sectioning doc comments.
2016-12-26 13:18:51 +10:30
Michael James Gratton
7654b16908 Add unit test for Geary.RFC822.Message::get_preview. 2016-12-23 10:38:23 +10:30
Michael James Gratton
1879ea8480 Combine fetch and convo message codepaths for generating preview text.
Ensures that both appear the same to the user, and that the conversation
message preview gets the same armour and quote stripping that the fecth
preview does.

Added tests.

Bug 714317

* src/engine/rfc822/rfc822-utils.vala
  (Geary.RFC822.Utils::to_preview_text): New common function to handle
  generating a preview from a RFC 822 plain text or HTML string.

* src/engine/rfc822/rfc822-message-data.vala (PreviewText::with_header):
  Move plain text armour and quote stripping to to_preview_text(), call
  that to generate preview text.

* src/engine/rfc822/rfc822-message.vala (Message::get_preview): call
  to_preview_text() to generate the preview text.
2016-12-19 18:47:38 +11:00
Michael James Gratton
deb0c415d0 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-19 00:45:41 +11:00
Michael James Gratton
7683044d61 Add an initial/example unit test. 2016-12-13 11:27:19 +11:00
Michael James Gratton
6ce262a3b7 Basic unit test build configuration. 2016-12-13 11:27:15 +11:00