summaryrefslogtreecommitdiff
path: root/test/urldbtest.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/urldbtest.c')
-rw-r--r--test/urldbtest.c610
1 files changed, 463 insertions, 147 deletions
diff --git a/test/urldbtest.c b/test/urldbtest.c
index bc707edfb..1c76de1ee 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -43,13 +43,94 @@
#include "desktop/gui_internal.h"
#include "desktop/cookie_manager.h"
+/**
+ * url database used as input to test sets
+ */
const char *test_urldb_path = "test/data/urldb";
+/**
+ * url database used as output reference
+ */
+const char *test_urldb_out_path = "test/data/urldb-out";
+
+/**
+ * cookie database used as input
+ */
const char *test_cookies_path = "test/data/cookies";
+/**
+ * cookie database used as output reference
+ */
+const char *test_cookies_out_path = "test/data/cookies-out";
const char *wikipedia_url = "http://www.wikipedia.org/";
struct netsurf_table *guit = NULL;
+
+struct test_urls {
+ const char* url;
+ const char* title;
+ const content_type type;
+ const bool persistent;
+};
+
+
+#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
+
+
+/* Stubs */
+nserror nslog_set_filter_by_options() { return NSERROR_OK; }
+
+/**
+ * generate test output filenames
+ */
+static char *testnam(char *out)
+{
+ static int count = 0;
+ static char name[64];
+ snprintf(name, 64, "/tmp/urldbtest%d-%d", getpid(), count);
+ count++;
+ return name;
+}
+
+/**
+ * compare two files contents
+ */
+static int cmp(const char *f1, const char *f2)
+{
+ int res = 0;
+ FILE *fp1;
+ FILE *fp2;
+ int ch1;
+ int ch2;
+
+ fp1 = fopen(f1, "r");
+ if (fp1 == NULL) {
+ return -1;
+ }
+ fp2 = fopen(f2, "r");
+ if (fp2 == NULL) {
+ fclose(fp1);
+ return -1;
+ }
+
+ while (res == 0) {
+ ch1 = fgetc(fp1);
+ ch2 = fgetc(fp2);
+
+ if (ch1 != ch2) {
+ res = 1;
+ }
+
+ if (ch1 == EOF) {
+ break;
+ }
+ }
+
+ fclose(fp1);
+ fclose(fp2);
+ return res;
+}
+
/*************** original test helpers ************/
bool cookie_manager_add(const struct cookie_data *data)
@@ -65,33 +146,12 @@ static nsurl *make_url(const char *url)
{
nsurl *nsurl;
if (nsurl_create(url, &nsurl) != NSERROR_OK) {
- LOG("failed creating nsurl");
+ NSLOG(netsurf, INFO, "failed creating nsurl");
exit(1);
}
return nsurl;
}
-static char *make_path_query(nsurl *url)
-{
- size_t len;
- char *path_query;
- if (nsurl_get(url, NSURL_PATH | NSURL_QUERY, &path_query, &len) !=
- NSERROR_OK) {
- LOG("failed creating path_query");
- exit(1);
- }
- return path_query;
-}
-
-static lwc_string *make_lwc(const char *str)
-{
- lwc_string *lwc;
- if (lwc_intern_string(str, strlen(str), &lwc) != lwc_error_ok) {
- LOG("failed creating lwc_string");
- exit(1);
- }
- return lwc;
-}
static bool test_urldb_set_cookie(const char *header, const char *url,
const char *referer)
@@ -172,9 +232,8 @@ static void urldb_lwc_iterator(lwc_string *str, void *pw)
{
int *scount = pw;
- LOG("[%3u] %.*s", str->refcnt,
- (int)lwc_string_length(str),
- lwc_string_data(str));
+ NSLOG(netsurf, INFO, "[%3u] %.*s", str->refcnt,
+ (int)lwc_string_length(str), lwc_string_data(str));
(*scount)++;
}
@@ -188,7 +247,7 @@ static void urldb_teardown(void)
corestrings_fini();
- LOG("Remaining lwc strings:");
+ NSLOG(netsurf, INFO, "Remaining lwc strings:");
lwc_iterate_strings(urldb_lwc_iterator, &scount);
ck_assert_int_eq(scount, 0);
}
@@ -199,67 +258,28 @@ static void urldb_teardown(void)
START_TEST(urldb_original_test)
{
- struct host_part *h;
- struct path_data *p;
- const struct url_data *u;
- lwc_string *scheme;
- lwc_string *fragment;
nsurl *url;
nsurl *urlr;
- char *path_query;
-
- h = urldb_add_host("127.0.0.1");
- ck_assert_msg(h != NULL, "failed adding host");
-
- h = urldb_add_host("intranet");
- ck_assert_msg(h != NULL, "failed adding host");
-
- url = make_url("http://intranet/");
- scheme = nsurl_get_component(url, NSURL_SCHEME);
- p = urldb_add_path(scheme, 0, h, strdup("/"), NULL, url);
- ck_assert_msg(p != NULL, "failed adding path");
- lwc_string_unref(scheme);
-
- urldb_set_url_title(url, "foo");
-
- u = urldb_get_url_data(url);
- assert(u && strcmp(u->title, "foo") == 0);
- nsurl_unref(url);
-
- /* Get host entry */
- h = urldb_add_host("netsurf.strcprstskrzkrk.co.uk");
- ck_assert_msg(h != NULL, "failed adding host");
-
- /* Get path entry */
+ /* fragments */
url = make_url("http://netsurf.strcprstskrzkrk.co.uk/path/to/resource.htm?a=b");
- scheme = nsurl_get_component(url, NSURL_SCHEME);
- path_query = make_path_query(url);
- fragment = make_lwc("zz");
- p = urldb_add_path(scheme, 0, h, strdup(path_query), fragment, url);
- ck_assert_msg(p != NULL, "failed adding path");
-
- lwc_string_unref(fragment);
-
- fragment = make_lwc("aa");
- p = urldb_add_path(scheme, 0, h, strdup(path_query), fragment, url);
- ck_assert_msg(p != NULL, "failed adding path");
-
- lwc_string_unref(fragment);
+ ck_assert(urldb_add_url(url) == true);
+ nsurl_unref(url);
- fragment = make_lwc("yy");
- p = urldb_add_path(scheme, 0, h, strdup(path_query), fragment, url);
- ck_assert_msg(p != NULL, "failed adding path");
+ url = make_url("http://netsurf.strcprstskrzkrk.co.uk/path/to/resource.htm#zz?a=b");
+ ck_assert(urldb_add_url(url) == true);
+ nsurl_unref(url);
- free(path_query);
- lwc_string_unref(fragment);
- lwc_string_unref(scheme);
+ url = make_url("http://netsurf.strcprstskrzkrk.co.uk/path/to/resource.htm#aa?a=b");
+ ck_assert(urldb_add_url(url) == true);
nsurl_unref(url);
- url = make_url("file:///home/");
- urldb_add_url(url);
+ url = make_url("http://netsurf.strcprstskrzkrk.co.uk/path/to/resource.htm#yy?a=b");
+ ck_assert(urldb_add_url(url) == true);
nsurl_unref(url);
+
+ /* set cookies on urls */
url = make_url("http://www.minimarcos.org.uk/cgi-bin/forum/Blah.pl?,v=login,p=2");
urldb_set_cookie("mmblah=foo; path=/; expires=Thur, 31-Dec-2099 00:00:00 GMT\r\n", url, NULL);
nsurl_unref(url);
@@ -292,37 +312,6 @@ START_TEST(urldb_original_test)
urldb_get_cookie(url, true);
nsurl_unref(url);
- /* Mantis bug #993 */
- url = make_url("http:moodle.org");
- ck_assert(urldb_add_url(url) == true);
- ck_assert(urldb_get_url(url) != NULL);
- nsurl_unref(url);
-
- /* Mantis bug #993 */
- url = make_url("http://a_a/");
- ck_assert(urldb_add_url(url));
- ck_assert(urldb_get_url(url));
- nsurl_unref(url);
-
- /* Mantis bug #996 */
- url = make_url("http://foo@moose.com/");
- if (urldb_add_url(url)) {
- LOG("added %s", nsurl_access(url));
- ck_assert(urldb_get_url(url) != NULL);
- }
- nsurl_unref(url);
-
- /* Mantis bug #913 */
- url = make_url("http://www2.2checkout.com/");
- ck_assert(urldb_add_url(url));
- ck_assert(urldb_get_url(url));
- nsurl_unref(url);
-
- /* Numeric subdomains */
- url = make_url("http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg");
- ck_assert(urldb_add_url(url));
- ck_assert(urldb_get_url(url));
- nsurl_unref(url);
/* Valid path */
ck_assert(test_urldb_set_cookie("name=value;Path=/\r\n", "http://www.google.com/", NULL));
@@ -332,16 +321,16 @@ START_TEST(urldb_original_test)
/* Defaulted path */
ck_assert(test_urldb_set_cookie("name=value\r\n", "http://www.example.org/foo/bar/baz/bat.html", NULL));
- ck_assert(test_urldb_get_cookie("http://www.example.org/foo/bar/baz/quux.htm"));
+ ck_assert(test_urldb_get_cookie("http://www.example.org/foo/bar/baz/quux.htm") != NULL);
/* Defaulted path with no non-leaf path segments */
ck_assert(test_urldb_set_cookie("name=value\r\n", "http://no-non-leaf.example.org/index.html", NULL));
- ck_assert(test_urldb_get_cookie("http://no-non-leaf.example.org/page2.html"));
- ck_assert(test_urldb_get_cookie("http://no-non-leaf.example.org/"));
+ ck_assert(test_urldb_get_cookie("http://no-non-leaf.example.org/page2.html") != NULL);
+ ck_assert(test_urldb_get_cookie("http://no-non-leaf.example.org/") != NULL);
/* Valid path (includes leafname) */
ck_assert(test_urldb_set_cookie("name=value;Version=1;Path=/index.cgi\r\n", "http://example.org/index.cgi", NULL));
- ck_assert(test_urldb_get_cookie("http://example.org/index.cgi"));
+ ck_assert(test_urldb_get_cookie("http://example.org/index.cgi") != NULL);
/* Valid path (includes leafname in non-root directory) */
ck_assert(test_urldb_set_cookie("name=value;Path=/foo/index.html\r\n", "http://www.example.org/foo/index.html", NULL));
@@ -401,6 +390,12 @@ START_TEST(urldb_original_test)
}
END_TEST
+/**
+ * test case comprised of tests historicaly found in netsurf
+ *
+ * These tests are carried forward from original open coded tests
+ * found in the url database code.
+ */
static TCase *urldb_original_case_create(void)
{
TCase *tc;
@@ -416,6 +411,172 @@ static TCase *urldb_original_case_create(void)
return tc;
}
+
+/**
+ * add set and get tests
+ */
+static const struct test_urls add_set_get_tests[] = {
+ {
+ "http://intranet/",
+ "foo",
+ CONTENT_HTML,
+ false
+ }, /* from legacy tests */
+ {
+ "http:moodle.org",
+ "buggy",
+ CONTENT_HTML,
+ false
+ }, /* Mantis bug #993 */
+ {
+ "http://a_a/",
+ "buggsy",
+ CONTENT_HTML,
+ false
+ }, /* Mantis bug #993 */
+ {
+ "http://www2.2checkout.com/",
+ "foobar",
+ CONTENT_HTML,
+ false
+ }, /* Mantis bug #913 */
+ {
+ "http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg",
+ "a more complex title",
+ CONTENT_IMAGE,
+ true
+ }, /* Numeric subdomains */
+ {
+ "http://tree.example.com/this_url_has_a_ridiculously_long_path/made_up_from_a_number_of_inoranately_long_elments_some_of_well_over_forty/characters_in_length/the_whole_path_comes_out_well_in_excess_of_two_hundred_characters_in_length/this_is_intended_to_try_and_drive/the_serialisation_code_mad/foo.png",
+ NULL,
+ CONTENT_IMAGE,
+ false
+ },
+ {
+ "https://tree.example.com:8080/example.png",
+ "fishy port ",
+ CONTENT_HTML,
+ false
+ },
+ {
+ "http://tree.example.com/bar.png",
+ "\t ",
+ CONTENT_IMAGE,
+ false
+ }, /* silly title */
+ {
+ "http://[2001:db8:1f70::999:de8:7648:6e8]:100/",
+ "ipv6 with port",
+ CONTENT_TEXTPLAIN,
+ false
+ },
+ {
+ "file:///home/",
+ NULL,
+ CONTENT_HTML,
+ false
+ }, /* no title */
+ {
+ "http://foo@moose.com/",
+ NULL,
+ CONTENT_HTML,
+ false
+ }, /* Mantis bug #996 */
+ {
+ "http://a.xn--11b4c3d/a",
+ "a title",
+ CONTENT_HTML,
+ false
+ },
+ {
+ "https://smog.大众汽车/test",
+ "unicode title 大众汽车",
+ CONTENT_HTML,
+ false
+ },
+};
+
+
+/**
+ * add set and get test
+ */
+START_TEST(urldb_add_set_get_test)
+{
+ nserror err;
+ nsurl *url;
+ nsurl *res_url;
+ const struct url_data *data;
+ const struct test_urls *tst = &add_set_get_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->url, &url);
+ ck_assert(err == NSERROR_OK);
+
+ /* add the url to the database */
+ ck_assert(urldb_add_url(url) == true);
+
+ /* set title */
+ err = urldb_set_url_title(url, tst->title);
+ ck_assert(err == NSERROR_OK);
+
+ err = urldb_set_url_content_type(url, tst->type);
+ ck_assert(err == NSERROR_OK);
+
+ /* retrieve the url from the database and check it matches */
+ res_url = urldb_get_url(url);
+ ck_assert(res_url != NULL);
+ ck_assert(nsurl_compare(url, res_url, NSURL_COMPLETE) == true);
+
+ /* retrieve url data and check title matches */
+ data = urldb_get_url_data(url);
+ ck_assert(data != NULL);
+
+ /* ensure title matches */
+ if (tst->title != NULL) {
+ ck_assert_str_eq(data->title, tst->title);
+ } else {
+ ck_assert(data->title == NULL);
+ }
+
+ /* ensure type matches */
+ ck_assert(data->type == tst->type);
+
+ /* release test url */
+ nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * test cases that simply add and then get a url
+ *
+ * these tests exercise the adding and retrival of urls verifying the
+ * data added.
+ */
+static TCase *urldb_add_get_case_create(void)
+{
+ TCase *tc;
+ tc = tcase_create("Add Get tests");
+
+ /* ensure corestrings are initialised and finalised for every test */
+ tcase_add_checked_fixture(tc,
+ urldb_create,
+ urldb_teardown);
+
+ tcase_add_loop_test(tc,
+ urldb_add_set_get_test,
+ 0, NELEMS(add_set_get_tests));
+
+ return tc;
+}
+
+/**
+ * Session basic test case
+ *
+ * The databases are loaded and saved with no manipulation
+ *
+ * \warning This test will fail when 32bit time_t wraps in 2038 as the
+ * cookie database expiry field is limited to that size.
+ */
START_TEST(urldb_session_test)
{
nserror res;
@@ -431,16 +592,26 @@ START_TEST(urldb_session_test)
urldb_load_cookies(test_cookies_path);
/* write database out */
- outnam = tmpnam(NULL);
+ outnam = testnam(NULL);
res = urldb_save(outnam);
ck_assert_int_eq(res, NSERROR_OK);
+ /* check the url database file written and the test file match */
+ ck_assert_int_eq(cmp(outnam, test_urldb_out_path), 0);
+
/* remove test output */
unlink(outnam);
/* write cookies out */
+ outnam = testnam(NULL);
urldb_save_cookies(outnam);
+ /* check the cookies file written and the test file match */
+ ck_assert_int_eq(cmp(outnam, test_cookies_out_path), 0);
+
+ /* remove test output */
+ unlink(outnam);
+
/* finalise options */
res = nsoption_finalise(NULL, NULL);
ck_assert_int_eq(res, NSERROR_OK);
@@ -448,7 +619,81 @@ START_TEST(urldb_session_test)
}
END_TEST
+/**
+ * Session more extensive test case
+ *
+ * The databases are loaded and saved with a host and paths added
+ */
+START_TEST(urldb_session_add_test)
+{
+ nserror res;
+ char *outnam;
+ nsurl *url;
+ unsigned int t;
+
+ /* writing output requires options initialising */
+ res = nsoption_init(NULL, NULL, NULL);
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ res = urldb_load(test_urldb_path);
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ urldb_load_cookies(test_cookies_path);
+
+ /* add to db */
+ for (t = 0; t < NELEMS(add_set_get_tests); t++) {
+ const struct test_urls *tst = &add_set_get_tests[t];
+ /* not testing url creation, this should always succeed */
+ res = nsurl_create(tst->url, &url);
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ /* add the url to the database */
+ ck_assert(urldb_add_url(url) == true);
+
+ /* set title */
+ res = urldb_set_url_title(url, tst->title);
+ ck_assert(res == NSERROR_OK);
+
+ /* update the visit time so it gets serialised */
+ if (tst->persistent) {
+ res = urldb_set_url_persistence(url, true);
+ } else {
+ res = urldb_update_url_visit_data(url);
+ }
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ nsurl_unref(url);
+ }
+
+ /* write database out */
+ outnam = testnam(NULL);
+ res = urldb_save(outnam);
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ /* remove urldb test output */
+ unlink(outnam);
+
+ /* write cookies out */
+ outnam = testnam(NULL);
+ urldb_save_cookies(outnam);
+
+ /* remove cookies test output */
+ unlink(outnam);
+
+ /* finalise options */
+ res = nsoption_finalise(NULL, NULL);
+ ck_assert_int_eq(res, NSERROR_OK);
+
+}
+END_TEST
+
+/**
+ * Test case to check entire session
+ *
+ * These tests define a session as loading a url database and cookie
+ * database and then saving them back to disc.
+ */
static TCase *urldb_session_case_create(void)
{
TCase *tc;
@@ -460,6 +705,7 @@ static TCase *urldb_session_case_create(void)
urldb_teardown);
tcase_add_test(tc, urldb_session_test);
+ tcase_add_test(tc, urldb_session_add_test);
return tc;
}
@@ -468,7 +714,7 @@ static int cb_count;
static bool urldb_iterate_entries_cb(nsurl *url, const struct url_data *data)
{
- LOG("url: %s", nsurl_access(url));
+ NSLOG(netsurf, INFO, "url: %s", nsurl_access(url));
/* fprintf(stderr, "url:%s\ntitle:%s\n\n",nsurl_access(url), data->title); */
cb_count++;
return true;
@@ -538,9 +784,9 @@ START_TEST(urldb_iterate_partial_path_test)
END_TEST
/**
- * iterate through partial matches
+ * iterate through partial matches of numeric v4 address
*/
-START_TEST(urldb_iterate_partial_numeric_test)
+START_TEST(urldb_iterate_partial_numeric_v4_test)
{
nsurl *url;
@@ -555,49 +801,74 @@ START_TEST(urldb_iterate_partial_numeric_test)
cb_count = 0;
urldb_iterate_partial("192.168.7.1/", urldb_iterate_entries_cb);
ck_assert_int_eq(cb_count, 1);
-
-
}
END_TEST
-START_TEST(urldb_auth_details_test)
+
+/**
+ * iterate through partial matches of numeric v6 address
+ */
+START_TEST(urldb_iterate_partial_numeric_v6_test)
{
nsurl *url;
- const char *res;
- const char *auth = "mooooo";
- url = make_url(wikipedia_url);
- urldb_set_auth_details(url, "tree", auth);
-
- res = urldb_get_auth_details(url, "tree");
- ck_assert_str_eq(res, auth);
+ cb_count = 0;
+ urldb_iterate_partial("[2001:db8:1f70::999:de8:7648:6e8]",
+ urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 0);
+ url = make_url("http://[2001:db8:1f70::999:de8:7648:6e8]/index.html");
+ urldb_add_url(url);
nsurl_unref(url);
+
+ cb_count = 0;
+ urldb_iterate_partial("[2001:db8:1f70::999:de8:7648:6e8]/index.wrong",
+ urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 0);
+
+ cb_count = 0;
+ urldb_iterate_partial("[2001:db8:1f70::999:de8:7648:6e8]",
+ urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 1);
+
+ cb_count = 0;
+ urldb_iterate_partial("[2001:db8:1f70::999:de8:7648:6e8]/in",
+ urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 1);
+
+ /* double path separators are ignored */
+ cb_count = 0;
+ urldb_iterate_partial("[2001:db8:1f70::999:de8:7648:6e8]//index.html",
+ urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 1);
+
+ /* bad ipv6 address inet_pton should fail with this */
+ cb_count = 0;
+ urldb_iterate_partial("[2001::1f70::999::7648:8]",
+ urldb_iterate_entries_cb);
+ ck_assert_int_eq(cb_count, 0);
+
}
END_TEST
-START_TEST(urldb_thumbnail_test)
+START_TEST(urldb_auth_details_test)
{
nsurl *url;
- struct bitmap *bmap;
- struct bitmap *res;
- bool set;
+ const char *res;
+ const char *auth = "mooooo";
url = make_url(wikipedia_url);
- bmap = (struct bitmap*)url;
-
- set = urldb_set_thumbnail(url, bmap);
- ck_assert(set == true);
+ urldb_set_auth_details(url, "tree", auth);
- res = urldb_get_thumbnail(url);
- ck_assert(res != NULL);
- ck_assert(res == bmap);
+ res = urldb_get_auth_details(url, "tree");
+ ck_assert_str_eq(res, auth);
nsurl_unref(url);
}
END_TEST
+
START_TEST(urldb_cert_permissions_test)
{
nsurl *url;
@@ -690,9 +961,9 @@ static TCase *urldb_case_create(void)
tcase_add_test(tc, urldb_iterate_partial_nomatch_test);
tcase_add_test(tc, urldb_iterate_partial_add_test);
tcase_add_test(tc, urldb_iterate_partial_path_test);
- tcase_add_test(tc, urldb_iterate_partial_numeric_test);
+ tcase_add_test(tc, urldb_iterate_partial_numeric_v4_test);
+ tcase_add_test(tc, urldb_iterate_partial_numeric_v6_test);
tcase_add_test(tc, urldb_auth_details_test);
- tcase_add_test(tc, urldb_thumbnail_test);
tcase_add_test(tc, urldb_cert_permissions_test);
tcase_add_test(tc, urldb_update_visit_test);
tcase_add_test(tc, urldb_reset_visit_test);
@@ -704,7 +975,7 @@ static TCase *urldb_case_create(void)
static bool urldb_iterate_cookies_cb(const struct cookie_data *data)
{
- LOG("%p", data);
+ NSLOG(netsurf, INFO, "%p", data);
/* fprintf(stderr, "domain:%s\npath:%s\nname:%s\n\n",data->domain, data->path, data->name);*/
return true;
}
@@ -769,16 +1040,56 @@ static TCase *urldb_cookie_case_create(void)
}
+/**
+ * Test urldb_add_url asserting on NULL.
+ */
+START_TEST(urldb_api_add_url_assert_test)
+{
+ bool res;
+ res = urldb_add_url(NULL);
+ ck_assert(res == true);
+}
+END_TEST
/**
- * Test urldb_add_host asserting on NULL.
+ * Test urldb find failing for differing bad url.
*/
-START_TEST(urldb_api_add_host_assert_test)
+START_TEST(urldb_api_url_find_test)
{
- struct host_part *res;
- res = urldb_add_host(NULL);
- ck_assert(res == NULL);
+ nsurl *url;
+ nserror res;
+
+ urldb_create();
+
+ /* search for a url with mailto scheme */
+ res = nsurl_create("mailto:", &url);
+ ck_assert_int_eq(res, NSERROR_OK);
+
+ res = urldb_set_url_persistence(url, true);
+ ck_assert_int_eq(res, NSERROR_NOT_FOUND);
+
+ nsurl_unref(url);
+
+ /* search for a url with odd scheme and no host */
+ res = nsurl_create("fish:///", &url);
+ ck_assert_int_eq(res, NSERROR_OK);
+ ck_assert(nsurl_has_component(url, NSURL_HOST) == false);
+
+ res = urldb_set_url_title(url, NULL);
+ ck_assert_int_eq(res, NSERROR_NOT_FOUND);
+
+ nsurl_unref(url);
+
+ /* search for a url with not found url */
+ res = nsurl_create("http://no.example.com/", &url);
+ ck_assert_int_eq(res, NSERROR_OK);
+ ck_assert(nsurl_has_component(url, NSURL_HOST) == true);
+
+ res = urldb_set_url_persistence(url, true);
+ ck_assert_int_eq(res, NSERROR_NOT_FOUND);
+
+ nsurl_unref(url);
}
END_TEST
@@ -801,22 +1112,27 @@ static TCase *urldb_api_case_create(void)
tc = tcase_create("API_checks");
tcase_add_test_raise_signal(tc,
- urldb_api_add_host_assert_test,
+ urldb_api_add_url_assert_test,
6);
+ tcase_add_test(tc, urldb_api_url_find_test);
+
tcase_add_test(tc, urldb_api_destroy_no_init_test);
return tc;
}
-
+/**
+ * Test suite for url database
+ */
static Suite *urldb_suite_create(void)
{
Suite *s;
s = suite_create("URLDB");
suite_add_tcase(s, urldb_api_case_create());
+ suite_add_tcase(s, urldb_add_get_case_create());
suite_add_tcase(s, urldb_session_case_create());
suite_add_tcase(s, urldb_case_create());
suite_add_tcase(s, urldb_cookie_case_create());