add urldb tests for content type setting

This commit is contained in:
Vincent Sanders 2017-03-13 22:04:38 +00:00
parent 27aa56cbf6
commit 6eff2522c8
2 changed files with 23 additions and 19 deletions

View File

@ -23,8 +23,8 @@
* The content enumerations are defined here. * The content enumerations are defined here.
*/ */
#ifndef _NETSURF_CONTENT_TYPE_H_ #ifndef NETSURF_CONTENT_TYPE_H
#define _NETSURF_CONTENT_TYPE_H_ #define NETSURF_CONTENT_TYPE_H
/** Debugging dump operations */ /** Debugging dump operations */
enum content_debug { enum content_debug {

View File

@ -69,8 +69,8 @@ struct netsurf_table *guit = NULL;
struct test_urls { struct test_urls {
const char* url; const char* url;
const char* title; const char* title;
const char* res; const content_type type;
bool persistent; const bool persistent;
}; };
@ -417,73 +417,73 @@ static const struct test_urls add_set_get_tests[] = {
{ {
"http://intranet/", "http://intranet/",
"foo", "foo",
NULL, CONTENT_HTML,
false false
}, /* from legacy tests */ }, /* from legacy tests */
{ {
"http:moodle.org", "http:moodle.org",
"buggy", "buggy",
NULL, CONTENT_HTML,
false false
}, /* Mantis bug #993 */ }, /* Mantis bug #993 */
{ {
"http://a_a/", "http://a_a/",
"buggsy", "buggsy",
NULL, CONTENT_HTML,
false false
}, /* Mantis bug #993 */ }, /* Mantis bug #993 */
{ {
"http://www2.2checkout.com/", "http://www2.2checkout.com/",
"foobar", "foobar",
NULL, CONTENT_HTML,
false false
}, /* Mantis bug #913 */ }, /* Mantis bug #913 */
{ {
"http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg", "http://2.bp.blogspot.com/_448y6kVhntg/TSekubcLJ7I/AAAAAAAAHJE/yZTsV5xT5t4/s1600/covers.jpg",
"a more complex title", "a more complex title",
NULL, CONTENT_IMAGE,
true true
}, /* Numeric subdomains */ }, /* 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", "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,
NULL, CONTENT_IMAGE,
false false
}, },
{ {
"https://tree.example.com:8080/example.png", "https://tree.example.com:8080/example.png",
"fishy port ", "fishy port ",
NULL, CONTENT_HTML,
false false
}, },
{ {
"http://[2001:db8:1f70::999:de8:7648:6e8]:100/", "http://[2001:db8:1f70::999:de8:7648:6e8]:100/",
"ipv6 with port", "ipv6 with port",
NULL, CONTENT_TEXTPLAIN,
false false
}, },
{ {
"file:///home/", "file:///home/",
NULL, NULL,
NULL, CONTENT_HTML,
false false
}, /* no title */ }, /* no title */
{ {
"http://foo@moose.com/", "http://foo@moose.com/",
NULL, NULL,
NULL, CONTENT_HTML,
false false
}, /* Mantis bug #996 */ }, /* Mantis bug #996 */
{ {
"http://a.xn--11b4c3d/a", "http://a.xn--11b4c3d/a",
"a title", "a title",
NULL, CONTENT_HTML,
false false
}, },
{ {
"https://smog.大众汽车/test", "https://smog.大众汽车/test",
"unicode title 大众汽车", "unicode title 大众汽车",
NULL, CONTENT_HTML,
false false
}, },
}; };
@ -511,6 +511,9 @@ START_TEST(urldb_add_set_get_test)
err = urldb_set_url_title(url, tst->title); err = urldb_set_url_title(url, tst->title);
ck_assert(err == NSERROR_OK); 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 */ /* retrieve the url from the database and check it matches */
res_url = urldb_get_url(url); res_url = urldb_get_url(url);
ck_assert(res_url != NULL); ck_assert(res_url != NULL);
@ -527,6 +530,9 @@ START_TEST(urldb_add_set_get_test)
ck_assert(data->title == NULL); ck_assert(data->title == NULL);
} }
/* ensure type matches */
ck_assert(data->type == tst->type);
/* release test url */ /* release test url */
nsurl_unref(url); nsurl_unref(url);
} }
@ -1034,7 +1040,7 @@ START_TEST(urldb_api_url_find_test)
ck_assert_int_eq(res, NSERROR_OK); ck_assert_int_eq(res, NSERROR_OK);
ck_assert(nsurl_has_component(url, NSURL_HOST) == false); 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); ck_assert_int_eq(res, NSERROR_NOT_FOUND);
nsurl_unref(url); nsurl_unref(url);
@ -1048,8 +1054,6 @@ START_TEST(urldb_api_url_find_test)
ck_assert_int_eq(res, NSERROR_NOT_FOUND); ck_assert_int_eq(res, NSERROR_NOT_FOUND);
nsurl_unref(url); nsurl_unref(url);
} }
END_TEST END_TEST