This ensures that non-breaking space chars (not HTML entities) are removed from text obtainined from the composer, and moves the F=F text formatting from JS back to Vala, to minimimse the JS footprint and return to using the old (working) version again. * src/client/composer/composer-web-view.vala (ClientWebView::get_text): Restore the old F=F formatting code previously in webkit-util, apply it to plain text obtained from the composer. * test/client/components/client-web-view-test-case.vala: New base class for tests involving ClientWebView. * test/client/composer/composer-web-view-test.vala: New tests for ComposerWebView::get_html and ::get_text. * test/js/composer-page-state-test.vala: Reworked to use ClientWebViewTestCase, updated tests now that JS is returning QUOTE_MARKER-delinated text, not F=F text. * test/testcase.vala (TestCase): Move ::async_complete and ::async_result from ComposerPageStateTest so all test cases can test async code. * test/CMakeLists.txt: Add new source files. * test/main.vala (main): Add new test. * ui/composer-web-view.js: Update doc comments, remove F=F code, break out non-breaking space replacement so it can be tested.
39 lines
1.1 KiB
Vala
39 lines
1.1 KiB
Vala
/*
|
|
* Copyright 2016 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.
|
|
*/
|
|
|
|
// Defined by CMake build script.
|
|
extern const string _BUILD_ROOT_DIR;
|
|
|
|
public abstract class ClientWebViewTestCase<V> : Gee.TestCase {
|
|
|
|
protected V test_view = null;
|
|
|
|
public ClientWebViewTestCase(string name) {
|
|
base(name);
|
|
}
|
|
|
|
public override void set_up() {
|
|
ClientWebView.init_web_context(File.new_for_path(_BUILD_ROOT_DIR).get_child("src"), true);
|
|
try {
|
|
ClientWebView.load_scripts();
|
|
} catch (Error err) {
|
|
assert_not_reached();
|
|
}
|
|
this.test_view = set_up_test_view();
|
|
}
|
|
|
|
protected abstract V set_up_test_view();
|
|
|
|
protected virtual void load_body_fixture(string? html = null) {
|
|
ClientWebView client_view = (ClientWebView) this.test_view;
|
|
client_view.load_html(html);
|
|
while (client_view.is_loading) {
|
|
Gtk.main_iteration();
|
|
}
|
|
}
|
|
|
|
}
|