diff options
author | Gero-Bare <gero.bare@gmail.com> | 2014-04-21 13:53:19 -0300 |
---|---|---|
committer | Gero-Bare <gero.bare@gmail.com> | 2014-04-21 13:53:19 -0300 |
commit | d96efd706d38c35b6cf2a139682f70e646bd99cc (patch) | |
tree | 7d92a54fa64534119c75768f66e568505f999b1b /tests | |
parent | 14038b5daa9347bde6c41b52bab3e71d3425da67 (diff) | |
parent | 33a8af5714fcf8bcdaa0ddfd710371be357975e5 (diff) | |
download | midori-d96efd706d38c35b6cf2a139682f70e646bd99cc.tar.gz |
Merge with lp:midori.
Fix some inconsitent spacing, remove some tab among other stylish issues.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 13 | ||||
-rw-r--r-- | tests/extensions.c | 43 | ||||
-rw-r--r-- | tests/searchaction.vala | 24 | ||||
-rw-r--r-- | tests/tab.vala | 13 |
4 files changed, 66 insertions, 27 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7782ff77..54b66808 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -46,9 +46,20 @@ foreach(UNIT_SRC ${TESTS}) ${LIBMIDORI} ) add_test(NAME ${UNIT} COMMAND ${UNIT}) - contain_test (${UNIT}) + contain_test (${UNIT} ${UNIT}) endforeach () +file(GLOB TESTS ${CMAKE_BINARY_DIR}/extensions/lib*.so) +foreach(UNIT ${TESTS}) + string(REPLACE ${CMAKE_BINARY_DIR} "" TEST ${UNIT}) + string(REPLACE "/" "-" TEST ${TEST}) + string(REPLACE "-extensions-lib" "" TEST ${TEST}) + string(REPLACE ".so" "" TEST ${TEST}) + add_test(NAME ${TEST} COMMAND $<TARGET_FILE:extensions> -e ${UNIT}) + set(exe $<TARGET_FILE:extensions> -e ${UNIT}) + contain_test (${TEST} "${exe}") +endforeach() + file(GLOB TESTS *.sh) foreach(UNIT_SRC ${TESTS}) string(REPLACE ".sh" "" UNIT ${UNIT_SRC}) diff --git a/tests/extensions.c b/tests/extensions.c index 4fe3ddf6..327ba1ba 100644 --- a/tests/extensions.c +++ b/tests/extensions.c @@ -176,12 +176,11 @@ extension_activate (gconstpointer data) } static void -extension_load (const gchar* extension_path, - GDir* extension_dir) +extension_load (const gchar* absolute_filename) { - const gchar* filename; - while ((filename = g_dir_read_name (extension_dir))) - { + g_assert (g_access (absolute_filename, F_OK) == 0); + gchar* extension_path = g_path_get_dirname (absolute_filename); + gchar* filename = g_path_get_basename (absolute_filename); GObject* extension = midori_extension_load_from_file (extension_path, filename, FALSE, TRUE); if (KATZE_IS_ARRAY (extension)) { @@ -202,7 +201,6 @@ extension_load (const gchar* extension_path, g_test_add_data_func (path, extension, extension_activate); g_free (path); } - } } static void @@ -217,29 +215,32 @@ main (int argc, char** argv) { midori_test_init (&argc, &argv); - midori_app_setup (&argc, &argv, NULL); + gchar* extension; + GOptionEntry entries[] = { + { "extension", 'e', 0, G_OPTION_ARG_STRING, &extension, + "Execute cases defined in extension_init", "EXTENSION" }, + { NULL } + }; + extension = NULL; + midori_app_setup (&argc, &argv, entries); midori_paths_init (MIDORI_RUNTIME_MODE_NORMAL, NULL); #ifndef HAVE_WEBKIT2 soup_session_add_feature_by_type (webkit_get_default_session (), SOUP_TYPE_COOKIE_JAR); #endif - g_test_add_func ("/extensions/create", extension_create); - g_test_add_func ("/extensions/settings", extension_settings); - g_test_add_func ("/extensions/config", extension_config); - - if (g_module_supported ()) + if (extension == NULL) { - gchar* extension_path = midori_paths_get_lib_path (PACKAGE_NAME); - GDir* extension_dir = g_dir_open (extension_path, 0, NULL); - g_assert (extension_dir != NULL); - + g_test_add_func ("/extensions/create", extension_create); + g_test_add_func ("/extensions/settings", extension_settings); + g_test_add_func ("/extensions/config", extension_config); + } + else + { + g_assert (g_module_supported ()); /* We require that extensions can be loaded repeatedly */ - extension_load (extension_path, extension_dir); - extension_load (extension_path, extension_dir); - - g_dir_close (extension_dir); - g_free (extension_path); + extension_load (extension); + extension_load (extension); } return g_test_run (); diff --git a/tests/searchaction.vala b/tests/searchaction.vala index eab9843c..4ccb552a 100644 --- a/tests/searchaction.vala +++ b/tests/searchaction.vala @@ -38,10 +38,34 @@ void searchaction_form () { */ } +struct TokenSpec { + public string uri; + public string expected_token; +} + +const TokenSpec[] tokens = { + { "https://bugs.launchpad.net/midori/+bugs", "lnch" }, + { "https://duckduckgo.com/search", "dckd" }, + { "http://en.wikipedia.org/w/index.php?title=Special:Search&profile=default&search=%s&fulltext=Search&", "wkpd" }, + { "about:blank", "" }, + { "", "" }, + { "file:///", "" }, + { "file:///form.html", "" }, +}; + +void searchaction_token () { + foreach(var token in tokens) + { + Katze.assert_str_equal (token.uri, + Midori.SearchAction.token_for_uri(token.uri), token.expected_token); + } +} + void main (string[] args) { Test.init (ref args); Midori.App.setup (ref args, null); Test.add_func ("/searchaction/form", searchaction_form); + Test.add_func ("/searchaction/token", searchaction_token); Test.run (); } diff --git a/tests/tab.vala b/tests/tab.vala index d23486fc..3d1eb899 100644 --- a/tests/tab.vala +++ b/tests/tab.vala @@ -80,6 +80,8 @@ void tab_special () { Midori.Test.log_set_fatal_handler_for_icons (); var browser = new Midori.Browser (); + /* FIXME need proper stock extension mechanism */ + browser.activate_action ("libabout.so=true"); var settings = new Midori.WebSettings (); browser.set ("settings", settings); var tab = new Midori.View.with_title (); @@ -92,7 +94,6 @@ void tab_special () { do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED); assert (tab.is_blank ()); assert (tab.can_view_source ()); - assert (tab.special); assert (!tab.can_save ()); tab.set_uri ("about:private"); @@ -116,6 +117,8 @@ void tab_alias () { Midori.Test.log_set_fatal_handler_for_icons (); var browser = new Midori.Browser (); var settings = new Midori.WebSettings (); + /* FIXME need proper stock extension mechanism */ + browser.activate_action ("libabout.so=true"); browser.set ("settings", settings); var tab = new Midori.View.with_title (); tab.settings = new Midori.WebSettings (); @@ -126,7 +129,7 @@ void tab_alias () { tab.settings.tabhome = "http://.invalid/"; tab.set_uri ("about:new"); do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED); - assert (tab.uri == tab.settings.tabhome); + // FIXME: Katze.assert_str_equal ("about:new", tab.uri, tab.settings.tabhome); #if !HAVE_WEBKIT2 // Check that this is the real page, not white page with a URL assert (!tab.web_view.search_text ("about:", true, false, false)); @@ -135,7 +138,7 @@ void tab_alias () { tab.settings.tabhome = "about:blank"; tab.set_uri ("about:new"); do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED); - assert (tab.uri == tab.settings.tabhome); + // FIXME: Katze.assert_str_equal ("about:new", tab.uri, tab.settings.tabhome); #if !HAVE_WEBKIT2 // Check that this is the real page, not white page with a URL assert (!tab.web_view.search_text ("about:", true, false, false)); @@ -145,7 +148,7 @@ void tab_alias () { tab.settings.location_entry_search = "http://.invalid/"; tab.set_uri ("about:new"); do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED); - assert (tab.uri == tab.settings.location_entry_search); + // FIXME: Katze.assert_str_equal ("about:new", tab.uri, tab.settings.location_entry_search); #if !HAVE_WEBKIT2 // Check that this is the real page, not white page with a URL assert (!tab.web_view.search_text ("about:", true, false, false)); @@ -155,7 +158,7 @@ void tab_alias () { tab.settings.homepage = "http://.invalid/"; tab.set_uri ("about:new"); do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED); - assert (tab.uri == tab.settings.homepage); + // FIXME: Katze.assert_str_equal ("about:new", tab.uri, tab.settings.homepage); #if !HAVE_WEBKIT2 // Check that this is the real page, not white page with a URL assert (!tab.web_view.search_text ("about:", true, false, false)); |