Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/6eff2522c8cdb402abd54fd679309abb49136658
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/6eff2522c8cdb402abd54fd679309abb49136658
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/6eff2522c8cdb402abd54fd679309abb49136658

The branch, master has been updated
       via  6eff2522c8cdb402abd54fd679309abb49136658 (commit)
       via  27aa56cbf6d1f4862594ca0369aabcd56bf2aa48 (commit)
       via  d55d7f3e1e50ad4b5199d1ea84922fedff859e78 (commit)
       via  ce6c0b9026bbe663f0d8980acde937543baca522 (commit)
       via  92b5f114baef36bf7e41d711ac7b2b4a7189acbc (commit)
      from  9a004753d2c53062ed4a9dca94d6674e11df7e0f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=6eff2522c8cdb402abd54fd679309abb49136658
commit 6eff2522c8cdb402abd54fd679309abb49136658
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    add urldb tests for content type setting

diff --git a/include/netsurf/content_type.h b/include/netsurf/content_type.h
index b3d5743..ef654cd 100644
--- a/include/netsurf/content_type.h
+++ b/include/netsurf/content_type.h
@@ -23,8 +23,8 @@
  * The content enumerations are defined here.
  */
 
-#ifndef _NETSURF_CONTENT_TYPE_H_
-#define _NETSURF_CONTENT_TYPE_H_
+#ifndef NETSURF_CONTENT_TYPE_H
+#define NETSURF_CONTENT_TYPE_H
 
 /** Debugging dump operations */
 enum content_debug {
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 3c43833..d400c43 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -69,8 +69,8 @@ struct netsurf_table *guit = NULL;
 struct test_urls {
        const char* url;
        const char* title;
-       const char* res;
-       bool persistent;
+       const content_type type;
+       const bool persistent;
 };
 
 
@@ -417,73 +417,73 @@ static const struct test_urls add_set_get_tests[] = {
        {
                "http://intranet/";,
                "foo",
-               NULL,
+               CONTENT_HTML,
                false
        }, /* from legacy tests */
        {
                "http:moodle.org",
                "buggy",
-               NULL,
+               CONTENT_HTML,
                false
        }, /* Mantis bug #993 */
        {
                "http://a_a/";,
                "buggsy",
-               NULL,
+               CONTENT_HTML,
                false
        }, /* Mantis bug #993 */
        {
                "http://www2.2checkout.com/";,
                "foobar",
-               NULL,
+               CONTENT_HTML,
                false
        }, /* Mantis bug #913 */
        {
                
"http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg";,
                "a more complex title",
-               NULL,
+               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/foo.png";,
                NULL,
-               NULL,
+               CONTENT_IMAGE,
                false
        },
        {
                "https://tree.example.com:8080/example.png";,
                "fishy port       ",
-               NULL,
+               CONTENT_HTML,
                false
        },
        {
                "http://[2001:db8:1f70::999:de8:7648:6e8]:100/";,
                "ipv6 with port",
-               NULL,
+               CONTENT_TEXTPLAIN,
                false
        },
        {
                "file:///home/",
                NULL,
-               NULL,
+               CONTENT_HTML,
                false
        }, /* no title */
        {
                "http://[email protected]/";,
                NULL,
-               NULL,
+               CONTENT_HTML,
                false
        }, /* Mantis bug #996 */
        {
                "http://a.xn--11b4c3d/a";,
                "a title",
-               NULL,
+               CONTENT_HTML,
                false
        },
        {
                "https://smog.大众汽车/test";,
                "unicode title 大众汽车",
-               NULL,
+               CONTENT_HTML,
                false
        },
 };
@@ -511,6 +511,9 @@ START_TEST(urldb_add_set_get_test)
        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);
@@ -527,6 +530,9 @@ START_TEST(urldb_add_set_get_test)
                ck_assert(data->title == NULL);
        }
 
+       /* ensure type matches */
+       ck_assert(data->type == tst->type);
+
        /* release test url */
        nsurl_unref(url);
 }
@@ -1034,7 +1040,7 @@ START_TEST(urldb_api_url_find_test)
        ck_assert_int_eq(res, NSERROR_OK);
        ck_assert(nsurl_has_component(url, NSURL_HOST) == false);
 
-       res = urldb_set_url_persistence(url, true);
+       res = urldb_set_url_title(url, NULL);
        ck_assert_int_eq(res, NSERROR_NOT_FOUND);
 
        nsurl_unref(url);
@@ -1048,8 +1054,6 @@ START_TEST(urldb_api_url_find_test)
        ck_assert_int_eq(res, NSERROR_NOT_FOUND);
 
        nsurl_unref(url);
-
-
 }
 END_TEST
 


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=27aa56cbf6d1f4862594ca0369aabcd56bf2aa48
commit 27aa56cbf6d1f4862594ca0369aabcd56bf2aa48
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    make the urldb content type setting API return an error

diff --git a/content/urldb.c b/content/urldb.c
index b795ac3..f386aa9 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -3204,17 +3204,20 @@ nserror urldb_set_url_title(nsurl *url, const char 
*title)
 
 
 /* exported interface documented in content/urldb.h */
-void urldb_set_url_content_type(nsurl *url, content_type type)
+nserror urldb_set_url_content_type(nsurl *url, content_type type)
 {
        struct path_data *p;
 
        assert(url);
 
        p = urldb_find_url(url);
-       if (!p)
-               return;
+       if (!p) {
+               return NSERROR_NOT_FOUND;
+       }
 
        p->urld.type = type;
+
+       return NSERROR_OK;
 }
 
 
diff --git a/content/urldb.h b/content/urldb.h
index e316291..26b014d 100644
--- a/content/urldb.h
+++ b/content/urldb.h
@@ -69,8 +69,9 @@ nserror urldb_set_url_title(struct nsurl *url, const char 
*title);
  *
  * \param url The URL to look for
  * \param type The type to set
+ * \return NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database
  */
-void urldb_set_url_content_type(struct nsurl *url, content_type type);
+nserror urldb_set_url_content_type(struct nsurl *url, content_type type);
 
 
 /**


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=d55d7f3e1e50ad4b5199d1ea84922fedff859e78
commit d55d7f3e1e50ad4b5199d1ea84922fedff859e78
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    add urldb tests for urls which cannot be found

diff --git a/test/urldbtest.c b/test/urldbtest.c
index 01cee79..3c43833 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -1011,6 +1011,49 @@ END_TEST
 
 
 /**
+ * Test urldb find failing for differing bad url.
+ */
+START_TEST(urldb_api_url_find_test)
+{
+       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_persistence(url, true);
+       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
+
+/**
  * test url database finalisation without initialisation.
  */
 START_TEST(urldb_api_destroy_no_init_test)
@@ -1032,6 +1075,8 @@ static TCase *urldb_api_case_create(void)
                                    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);
 
 


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=ce6c0b9026bbe663f0d8980acde937543baca522
commit ce6c0b9026bbe663f0d8980acde937543baca522
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    add persistance flag tests to urldb

diff --git a/test/data/urldb b/test/data/urldb
index 07bf1f5..41c1a08 100644
--- a/test/data/urldb
+++ b/test/data/urldb
@@ -5,7 +5,7 @@ http
 
 /wiki/Main_Page
 1
-2100000000
+1000000000
 0
 
 
diff --git a/test/data/urldb-out b/test/data/urldb-out
index 6fd2024..6db02bc 100644
--- a/test/data/urldb-out
+++ b/test/data/urldb-out
@@ -1,14 +1,6 @@
 106
 en.wikipedia.org
-2
-http
-
-/wiki/Main_Page
 1
-2100000000
-0
-
-
 https
 
 /wiki/Main_Page
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 19d0f9e..01cee79 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -66,10 +66,11 @@ const char *wikipedia_url = "http://www.wikipedia.org/";;
 struct netsurf_table *guit = NULL;
 
 
-struct test_triplets {
+struct test_urls {
        const char* url;
        const char* title;
        const char* res;
+       bool persistent;
 };
 
 
@@ -83,7 +84,7 @@ static char *testnam(char *out)
 {
        static int count = 0;
        static char name[64];
-       snprintf(name, 64, "/tmp/urldbtest%d", count);
+       snprintf(name, 64, "/tmp/urldbtest%d-%d", getpid(), count);
        count++;
        return name;
 }
@@ -255,11 +256,9 @@ static void urldb_teardown(void)
 
 START_TEST(urldb_original_test)
 {
-       const struct url_data *u;
        nsurl *url;
        nsurl *urlr;
 
-
        /* fragments */
        url = 
make_url("http://netsurf.strcprstskrzkrk.co.uk/path/to/resource.htm?a=b";);
        ck_assert(urldb_add_url(url) == true);
@@ -414,18 +413,79 @@ static TCase *urldb_original_case_create(void)
 /**
  * add set and get tests
  */
-static const struct test_triplets add_set_get_tests[] = {
-       { "http://intranet/";, "foo", NULL }, /* from legacy tests */
-       { "http:moodle.org", "buggy", NULL }, /* Mantis bug #993 */
-       { "http://a_a/";, "buggsy", NULL }, /* Mantis bug #993 */
-       { "http://www2.2checkout.com/"; , "foobar", NULL }, /* Mantis bug #913 */
-       { 
"http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg";,
-         "a more complex title" , NULL }, /* 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/foo.png";,
 NULL, NULL },
-       { "file:///home/", NULL, NULL}, /* no title */
-       { "http://[email protected]/";, NULL, NULL }, /* Mantis bug #996 */
-       { "http://a.xn--11b4c3d/a";, "a title", NULL },
-       { "https://smog.大众汽车/test";, "unicode title 大众汽车", NULL},
+static const struct test_urls add_set_get_tests[] = {
+       {
+               "http://intranet/";,
+               "foo",
+               NULL,
+               false
+       }, /* from legacy tests */
+       {
+               "http:moodle.org",
+               "buggy",
+               NULL,
+               false
+       }, /* Mantis bug #993 */
+       {
+               "http://a_a/";,
+               "buggsy",
+               NULL,
+               false
+       }, /* Mantis bug #993 */
+       {
+               "http://www2.2checkout.com/";,
+               "foobar",
+               NULL,
+               false
+       }, /* Mantis bug #913 */
+       {
+               
"http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg";,
+               "a more complex title",
+               NULL,
+               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/foo.png";,
+               NULL,
+               NULL,
+               false
+       },
+       {
+               "https://tree.example.com:8080/example.png";,
+               "fishy port       ",
+               NULL,
+               false
+       },
+       {
+               "http://[2001:db8:1f70::999:de8:7648:6e8]:100/";,
+               "ipv6 with port",
+               NULL,
+               false
+       },
+       {
+               "file:///home/",
+               NULL,
+               NULL,
+               false
+       }, /* no title */
+       {
+               "http://[email protected]/";,
+               NULL,
+               NULL,
+               false
+       }, /* Mantis bug #996 */
+       {
+               "http://a.xn--11b4c3d/a";,
+               "a title",
+               NULL,
+               false
+       },
+       {
+               "https://smog.大众汽车/test";,
+               "unicode title 大众汽车",
+               NULL,
+               false
+       },
 };
 
 
@@ -437,8 +497,8 @@ START_TEST(urldb_add_set_get_test)
        nserror err;
        nsurl *url;
        nsurl *res_url;
-       struct url_data *data;
-       const struct test_triplets *tst = &add_set_get_tests[_i];
+       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);
@@ -552,7 +612,7 @@ START_TEST(urldb_session_add_test)
        nserror res;
        char *outnam;
        nsurl *url;
-       int t;
+       unsigned int t;
 
        /* writing output requires options initialising */
        res = nsoption_init(NULL, NULL, NULL);
@@ -565,7 +625,7 @@ START_TEST(urldb_session_add_test)
 
        /* add to db */
        for (t = 0; t < NELEMS(add_set_get_tests); t++) {
-               const struct test_triplets *tst = &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);
@@ -574,8 +634,16 @@ START_TEST(urldb_session_add_test)
                /* 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 */
-               res = urldb_update_url_visit_data(url);
+               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);
@@ -966,6 +1034,7 @@ static TCase *urldb_api_case_create(void)
 
        tcase_add_test(tc, urldb_api_destroy_no_init_test);
 
+
        return tc;
 }
 


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=92b5f114baef36bf7e41d711ac7b2b4a7189acbc
commit 92b5f114baef36bf7e41d711ac7b2b4a7189acbc
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    make urldb persistance setting API return an error

diff --git a/content/urldb.c b/content/urldb.c
index 2c2ba15..b795ac3 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -3070,17 +3070,20 @@ nserror urldb_save(const char *filename)
 
 
 /* exported interface documented in content/urldb.h */
-void urldb_set_url_persistence(nsurl *url, bool persist)
+nserror urldb_set_url_persistence(nsurl *url, bool persist)
 {
        struct path_data *p;
 
        assert(url);
 
        p = urldb_find_url(url);
-       if (!p)
-               return;
+       if (!p) {
+               return NSERROR_NOT_FOUND;
+       }
 
        p->persistent = persist;
+
+       return NSERROR_OK;
 }
 
 
diff --git a/content/urldb.h b/content/urldb.h
index 734b94a..e316291 100644
--- a/content/urldb.h
+++ b/content/urldb.h
@@ -21,8 +21,8 @@
  * Unified URL information database internal interface.
  */
 
-#ifndef _NETSURF_CONTENT_URLDB_H_
-#define _NETSURF_CONTENT_URLDB_H_
+#ifndef NETSURF_CONTENT_URLDB_H
+#define NETSURF_CONTENT_URLDB_H
 
 #include <libwapcaplet/libwapcaplet.h>
 
@@ -40,8 +40,9 @@ void urldb_destroy(void);
  *
  * \param url Absolute URL to persist
  * \param persist True to persist, false otherwise
+ * \return NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database
  */
-void urldb_set_url_persistence(struct nsurl *url, bool persist);
+nserror urldb_set_url_persistence(struct nsurl *url, bool persist);
 
 
 /**
@@ -113,7 +114,7 @@ bool urldb_get_cert_permissions(struct nsurl *url);
  *
  * \param url Absolute URL to consider
  * \param bitmap Opaque pointer to thumbnail data, or NULL to invalidate
- * \return true on sucessful setting else false
+ * \return true on successful setting else false
  */
 bool urldb_set_thumbnail(struct nsurl *url, struct bitmap *bitmap);
 
@@ -123,7 +124,7 @@ bool urldb_set_thumbnail(struct nsurl *url, struct bitmap 
*bitmap);
  *
  * \param header Header to parse, with Set-Cookie: stripped
  * \param url URL being fetched
- * \param referer Referring resource, or 0 for verifiable transaction
+ * \param referrer Referring resource, or 0 for verifiable transaction
  * \return true on success, false otherwise
  */
 bool urldb_set_cookie(const char *header, struct nsurl *url, struct nsurl 
*referer);


-----------------------------------------------------------------------

Summary of changes:
 content/urldb.c                |   18 +++--
 content/urldb.h                |   14 ++--
 include/netsurf/content_type.h |    4 +-
 test/data/urldb                |    2 +-
 test/data/urldb-out            |    8 --
 test/urldbtest.c               |  162 ++++++++++++++++++++++++++++++++++------
 6 files changed, 163 insertions(+), 45 deletions(-)

diff --git a/content/urldb.c b/content/urldb.c
index 2c2ba15..f386aa9 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -3070,17 +3070,20 @@ nserror urldb_save(const char *filename)
 
 
 /* exported interface documented in content/urldb.h */
-void urldb_set_url_persistence(nsurl *url, bool persist)
+nserror urldb_set_url_persistence(nsurl *url, bool persist)
 {
        struct path_data *p;
 
        assert(url);
 
        p = urldb_find_url(url);
-       if (!p)
-               return;
+       if (!p) {
+               return NSERROR_NOT_FOUND;
+       }
 
        p->persistent = persist;
+
+       return NSERROR_OK;
 }
 
 
@@ -3201,17 +3204,20 @@ nserror urldb_set_url_title(nsurl *url, const char 
*title)
 
 
 /* exported interface documented in content/urldb.h */
-void urldb_set_url_content_type(nsurl *url, content_type type)
+nserror urldb_set_url_content_type(nsurl *url, content_type type)
 {
        struct path_data *p;
 
        assert(url);
 
        p = urldb_find_url(url);
-       if (!p)
-               return;
+       if (!p) {
+               return NSERROR_NOT_FOUND;
+       }
 
        p->urld.type = type;
+
+       return NSERROR_OK;
 }
 
 
diff --git a/content/urldb.h b/content/urldb.h
index 734b94a..26b014d 100644
--- a/content/urldb.h
+++ b/content/urldb.h
@@ -21,8 +21,8 @@
  * Unified URL information database internal interface.
  */
 
-#ifndef _NETSURF_CONTENT_URLDB_H_
-#define _NETSURF_CONTENT_URLDB_H_
+#ifndef NETSURF_CONTENT_URLDB_H
+#define NETSURF_CONTENT_URLDB_H
 
 #include <libwapcaplet/libwapcaplet.h>
 
@@ -40,8 +40,9 @@ void urldb_destroy(void);
  *
  * \param url Absolute URL to persist
  * \param persist True to persist, false otherwise
+ * \return NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database
  */
-void urldb_set_url_persistence(struct nsurl *url, bool persist);
+nserror urldb_set_url_persistence(struct nsurl *url, bool persist);
 
 
 /**
@@ -68,8 +69,9 @@ nserror urldb_set_url_title(struct nsurl *url, const char 
*title);
  *
  * \param url The URL to look for
  * \param type The type to set
+ * \return NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database
  */
-void urldb_set_url_content_type(struct nsurl *url, content_type type);
+nserror urldb_set_url_content_type(struct nsurl *url, content_type type);
 
 
 /**
@@ -113,7 +115,7 @@ bool urldb_get_cert_permissions(struct nsurl *url);
  *
  * \param url Absolute URL to consider
  * \param bitmap Opaque pointer to thumbnail data, or NULL to invalidate
- * \return true on sucessful setting else false
+ * \return true on successful setting else false
  */
 bool urldb_set_thumbnail(struct nsurl *url, struct bitmap *bitmap);
 
@@ -123,7 +125,7 @@ bool urldb_set_thumbnail(struct nsurl *url, struct bitmap 
*bitmap);
  *
  * \param header Header to parse, with Set-Cookie: stripped
  * \param url URL being fetched
- * \param referer Referring resource, or 0 for verifiable transaction
+ * \param referrer Referring resource, or 0 for verifiable transaction
  * \return true on success, false otherwise
  */
 bool urldb_set_cookie(const char *header, struct nsurl *url, struct nsurl 
*referer);
diff --git a/include/netsurf/content_type.h b/include/netsurf/content_type.h
index b3d5743..ef654cd 100644
--- a/include/netsurf/content_type.h
+++ b/include/netsurf/content_type.h
@@ -23,8 +23,8 @@
  * The content enumerations are defined here.
  */
 
-#ifndef _NETSURF_CONTENT_TYPE_H_
-#define _NETSURF_CONTENT_TYPE_H_
+#ifndef NETSURF_CONTENT_TYPE_H
+#define NETSURF_CONTENT_TYPE_H
 
 /** Debugging dump operations */
 enum content_debug {
diff --git a/test/data/urldb b/test/data/urldb
index 07bf1f5..41c1a08 100644
--- a/test/data/urldb
+++ b/test/data/urldb
@@ -5,7 +5,7 @@ http
 
 /wiki/Main_Page
 1
-2100000000
+1000000000
 0
 
 
diff --git a/test/data/urldb-out b/test/data/urldb-out
index 6fd2024..6db02bc 100644
--- a/test/data/urldb-out
+++ b/test/data/urldb-out
@@ -1,14 +1,6 @@
 106
 en.wikipedia.org
-2
-http
-
-/wiki/Main_Page
 1
-2100000000
-0
-
-
 https
 
 /wiki/Main_Page
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 19d0f9e..d400c43 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -66,10 +66,11 @@ const char *wikipedia_url = "http://www.wikipedia.org/";;
 struct netsurf_table *guit = NULL;
 
 
-struct test_triplets {
+struct test_urls {
        const char* url;
        const char* title;
-       const char* res;
+       const content_type type;
+       const bool persistent;
 };
 
 
@@ -83,7 +84,7 @@ static char *testnam(char *out)
 {
        static int count = 0;
        static char name[64];
-       snprintf(name, 64, "/tmp/urldbtest%d", count);
+       snprintf(name, 64, "/tmp/urldbtest%d-%d", getpid(), count);
        count++;
        return name;
 }
@@ -255,11 +256,9 @@ static void urldb_teardown(void)
 
 START_TEST(urldb_original_test)
 {
-       const struct url_data *u;
        nsurl *url;
        nsurl *urlr;
 
-
        /* fragments */
        url = 
make_url("http://netsurf.strcprstskrzkrk.co.uk/path/to/resource.htm?a=b";);
        ck_assert(urldb_add_url(url) == true);
@@ -414,18 +413,79 @@ static TCase *urldb_original_case_create(void)
 /**
  * add set and get tests
  */
-static const struct test_triplets add_set_get_tests[] = {
-       { "http://intranet/";, "foo", NULL }, /* from legacy tests */
-       { "http:moodle.org", "buggy", NULL }, /* Mantis bug #993 */
-       { "http://a_a/";, "buggsy", NULL }, /* Mantis bug #993 */
-       { "http://www2.2checkout.com/"; , "foobar", NULL }, /* Mantis bug #913 */
-       { 
"http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg";,
-         "a more complex title" , NULL }, /* 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/foo.png";,
 NULL, NULL },
-       { "file:///home/", NULL, NULL}, /* no title */
-       { "http://[email protected]/";, NULL, NULL }, /* Mantis bug #996 */
-       { "http://a.xn--11b4c3d/a";, "a title", NULL },
-       { "https://smog.大众汽车/test";, "unicode title 大众汽车", NULL},
+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/foo.png";,
+               NULL,
+               CONTENT_IMAGE,
+               false
+       },
+       {
+               "https://tree.example.com:8080/example.png";,
+               "fishy port       ",
+               CONTENT_HTML,
+               false
+       },
+       {
+               "http://[2001:db8:1f70::999:de8:7648:6e8]:100/";,
+               "ipv6 with port",
+               CONTENT_TEXTPLAIN,
+               false
+       },
+       {
+               "file:///home/",
+               NULL,
+               CONTENT_HTML,
+               false
+       }, /* no title */
+       {
+               "http://[email protected]/";,
+               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
+       },
 };
 
 
@@ -437,8 +497,8 @@ START_TEST(urldb_add_set_get_test)
        nserror err;
        nsurl *url;
        nsurl *res_url;
-       struct url_data *data;
-       const struct test_triplets *tst = &add_set_get_tests[_i];
+       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);
@@ -451,6 +511,9 @@ START_TEST(urldb_add_set_get_test)
        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);
@@ -467,6 +530,9 @@ START_TEST(urldb_add_set_get_test)
                ck_assert(data->title == NULL);
        }
 
+       /* ensure type matches */
+       ck_assert(data->type == tst->type);
+
        /* release test url */
        nsurl_unref(url);
 }
@@ -552,7 +618,7 @@ START_TEST(urldb_session_add_test)
        nserror res;
        char *outnam;
        nsurl *url;
-       int t;
+       unsigned int t;
 
        /* writing output requires options initialising */
        res = nsoption_init(NULL, NULL, NULL);
@@ -565,7 +631,7 @@ START_TEST(urldb_session_add_test)
 
        /* add to db */
        for (t = 0; t < NELEMS(add_set_get_tests); t++) {
-               const struct test_triplets *tst = &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);
@@ -574,8 +640,16 @@ START_TEST(urldb_session_add_test)
                /* 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 */
-               res = urldb_update_url_visit_data(url);
+               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);
@@ -943,6 +1017,47 @@ END_TEST
 
 
 /**
+ * Test urldb find failing for differing bad url.
+ */
+START_TEST(urldb_api_url_find_test)
+{
+       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
+
+/**
  * test url database finalisation without initialisation.
  */
 START_TEST(urldb_api_destroy_no_init_test)
@@ -964,8 +1079,11 @@ static TCase *urldb_api_case_create(void)
                                    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;
 }
 


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to