aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-08-07 21:28:21 +0800
committerXan Lopez <xan@igalia.com>2012-08-07 21:28:21 +0800
commit57b873b72f880e85fc0abd7ae26d627e1578a028 (patch)
tree20992ed907b712693ad8b19a6a187508317033b2 /tests
parenteea17ad5975842ba9a6c3e5ff0df08592ea2f5ee (diff)
downloadgsoc2013-epiphany-57b873b72f880e85fc0abd7ae26d627e1578a028.tar
gsoc2013-epiphany-57b873b72f880e85fc0abd7ae26d627e1578a028.tar.gz
gsoc2013-epiphany-57b873b72f880e85fc0abd7ae26d627e1578a028.tar.bz2
gsoc2013-epiphany-57b873b72f880e85fc0abd7ae26d627e1578a028.tar.lz
gsoc2013-epiphany-57b873b72f880e85fc0abd7ae26d627e1578a028.tar.xz
gsoc2013-epiphany-57b873b72f880e85fc0abd7ae26d627e1578a028.tar.zst
gsoc2013-epiphany-57b873b72f880e85fc0abd7ae26d627e1578a028.zip
ephy-web-view: do autosearch foo.bar strings where bar is not a TLD
Using the new SoupTLD methods. Had to split the non-search regexp in two so that we can reuse its 'is this a domain?' bits. Ugly as hell, but not worse than before... At least we have unit tests to catch regressions. https://bugzilla.gnome.org/show_bug.cgi?id=681022
Diffstat (limited to 'tests')
-rw-r--r--tests/ephy-web-view-test.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/ephy-web-view-test.c b/tests/ephy-web-view-test.c
index 19c9fdf7f..32a86db8d 100644
--- a/tests/ephy-web-view-test.c
+++ b/tests/ephy-web-view-test.c
@@ -235,19 +235,27 @@ static const RegexTest test_non_search_regex[] = {
static void
test_ephy_web_view_non_search_regex ()
{
- GRegex *regex;
+ GRegex *regex_non_search, *regex_domain;
GError *error = NULL;
int i;
- regex = g_regex_new (EPHY_WEB_VIEW_NON_SEARCH_REGEX,
- 0, G_REGEX_MATCH_NOTEMPTY, &error);
+ regex_non_search = g_regex_new (EPHY_WEB_VIEW_NON_SEARCH_REGEX,
+ 0, G_REGEX_MATCH_NOTEMPTY, &error);
if (error) {
g_test_message ("Regex failed: %s", error->message);
g_error_free (error);
}
+ g_assert (regex_non_search);
- g_assert (regex != NULL);
+ regex_domain = g_regex_new (EPHY_WEB_VIEW_DOMAIN_REGEX,
+ 0, G_REGEX_MATCH_NOTEMPTY, &error);
+
+ if (error) {
+ g_test_message ("Regex failed: %s", error->message);
+ g_error_free (error);
+ }
+ g_assert (regex_domain);
for (i = 0; i < G_N_ELEMENTS (test_non_search_regex); i++) {
RegexTest test;
@@ -258,10 +266,12 @@ test_ephy_web_view_non_search_regex ()
test.match ? "NO SEARCH" : "SEARCH",
test.url);
- g_assert (g_regex_match (regex, test.url, 0, NULL) == test.match);
+ g_assert (g_regex_match (regex_non_search, test.url, 0, NULL) == test.match ||
+ g_regex_match (regex_domain, test.url, 0, NULL) == test.match);
}
- g_regex_unref (regex);
+ g_regex_unref (regex_non_search);
+ g_regex_unref (regex_domain);
}
/* FIXME: we hardcode the google search for now, since it's the
@@ -274,7 +284,7 @@ static struct {
{ "http://google.com", "http://google.com" },
{ "search", "http://www.google.com/search?q=search&ie=UTF-8&oe=UTF-8" },
{ "search.me", "http://search.me" },
- { "lala.lala", "http://lala.lala" }, /* FIXME: should autosearch. */
+ { "lala.lala", "http://www.google.com/search?q=lala%2Elala&ie=UTF-8&oe=UTF-8" },
{ "127.0.0.1", "http://127.0.0.1" },
{ "http://127.0.0.1", "http://127.0.0.1" },
{ "totalgarbage0xdeadbeef", "http://www.google.com/search?q=totalgarbage0xdeadbeef&ie=UTF-8&oe=UTF-8" }