Gitweb links:
...log
http://git.netsurf-browser.org/libnslayout.git/shortlog/0aa5a727b3739a47a...
...commit
http://git.netsurf-browser.org/libnslayout.git/commit/0aa5a727b3739a47a5a...
...tree
http://git.netsurf-browser.org/libnslayout.git/tree/0aa5a727b3739a47a5a37...
The branch, master has been updated
via 0aa5a727b3739a47a5a37741eb72b691e8b8fe57 (commit)
via 2e86255e49f316c9749f350cf57d0f17a36abdaa (commit)
via a0ad0c682444aeb8e058f846fde121f061eb17b7 (commit)
via d01aac9ac10d902a799aade8270093bcba3e3a88 (commit)
from aed0dede52601d8e94f643c0b39a50da835ec8cd (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/libnslayout.git/commit/?id=0aa5a727b3739a4...
commit 0aa5a727b3739a47a5a37741eb72b691e8b8fe57
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add basic tests for creating a layout object.
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..5703e79
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,3 @@
+DIR_TEST_ITEMS := testrunner:tests.c;assert-tests.c;basic-layout-tests.c
+
+include $(NSBUILD)/Makefile.subdir
diff --git a/test/assert-tests.c b/test/assert-tests.c
new file mode 100644
index 0000000..4fca036
--- /dev/null
+++ b/test/assert-tests.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of LibNSLayout's tests
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include <check.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "tests.h"
+
+#ifndef UNUSED
+#define UNUSED(x) (void)(x)
+#endif
+
+/* TODO: Test for each individual param being NULL. */
+START_TEST (test_nslayout_layout_create_aborts1)
+{
+ nslayout_layout *layout;
+ (void) nslayout_layout_create(NULL, NULL, NULL, NULL, NULL, &layout);
+}
+END_TEST
+
+
+void nslayout_assert_suite(SRunner *sr)
+{
+ Suite *s = suite_create("libnslayout: API Assert tests");
+ TCase *tc_assert = tcase_create("Creation/Destruction");
+
+ tcase_add_test_raise_signal(
+ tc_assert,
+ test_nslayout_layout_create_aborts1,
+ SIGABRT);
+ suite_add_tcase(s, tc_assert);
+
+ srunner_add_suite(sr, s);
+}
diff --git a/test/basic-layout-tests.c b/test/basic-layout-tests.c
new file mode 100644
index 0000000..84611a9
--- /dev/null
+++ b/test/basic-layout-tests.c
@@ -0,0 +1,78 @@
+/*
+ * This file is part of LibNSLayout's tests
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include <check.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "tests.h"
+
+#ifndef UNUSED
+#define UNUSED(x) (void)(x)
+#endif
+
+int pw;
+
+static nslayout_error nslayout_test_callback(
+ nslayout_request *req,
+ nslayout_layout *layout,
+ void *pw)
+{
+ UNUSED(req);
+ UNUSED(layout);
+ UNUSED(pw);
+ return NSLAYOUT_OK;
+}
+
+START_TEST (test_nslayout_layout_create_ok)
+{
+ nslayout_layout *layout = NULL;
+ nslayout_error error;
+ dom_exception dom_error;
+ css_error css_err;
+ dom_document *doc;
+ css_select_ctx *css_ctx;
+ css_media_type media = CSS_MEDIA_SCREEN;
+
+ /* Create a DOM document */
+ dom_error = dom_implementation_create_document(DOM_IMPLEMENTATION_HTML,
+ NULL, NULL, NULL, NULL, NULL, &doc);
+ ck_assert(dom_error == DOM_NO_ERR);
+
+ /* Create a selection context (with no sheets added) */
+ css_err = css_select_ctx_create(&css_ctx);
+ ck_assert(css_err == CSS_OK);
+
+ error = nslayout_layout_create(doc,
+ css_ctx,
+ &media,
+ nslayout_test_callback,
+ &pw,
+ &layout);
+ fail_unless(error == NSLAYOUT_OK,
+ "Unable to create layout");
+ fail_unless(layout != NULL,
+ "Returned OK but str was still NULL");
+
+ css_err = css_select_ctx_destroy(css_ctx);
+ ck_assert(css_err == CSS_OK);
+
+ dom_node_unref(doc);
+}
+END_TEST
+
+
+void nslayout_basic_layout_suite(SRunner *sr)
+{
+ Suite *s = suite_create("libnslayout: basic layout tests");
+ TCase *tc_layout_basic = tcase_create("Creation/Destruction");
+
+ tcase_add_test(tc_layout_basic,
+ test_nslayout_layout_create_ok);
+ suite_add_tcase(s, tc_layout_basic);
+
+ srunner_add_suite(sr, s);
+}
diff --git a/test/tests.c b/test/tests.c
new file mode 100644
index 0000000..a58e038
--- /dev/null
+++ b/test/tests.c
@@ -0,0 +1,52 @@
+/*
+ * This file is part of LibNSLayout's tests
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include <check.h>
+
+#include "tests.h"
+
+#ifndef UNUSED
+#define UNUSED(x) ((x) = (x))
+#endif
+
+#ifndef NDEBUG
+/* This means that assertion failures are silent in tests */
+void __assert_fail(const char *__assertion, const char *__file,
+ unsigned int __line, const char *__function) {
+ (void)__assertion;
+ (void)__file;
+ (void)__line;
+ (void)__function;
+ abort();
+}
+#endif
+
+int main(int argc, char **argv)
+{
+ int number_failed = 0;
+ SRunner *sr;
+
+ UNUSED(argc);
+ UNUSED(argv);
+
+ sr = srunner_create(suite_create("Test suite for libnslayout"));
+
+#ifndef NDEBUG
+ nslayout_assert_suite(sr);
+#endif
+ nslayout_basic_layout_suite(sr);
+
+ srunner_set_fork_status(sr, CK_FORK);
+ srunner_run_all(sr, CK_ENV);
+ number_failed = srunner_ntests_failed(sr);
+
+ srunner_free(sr);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/test/tests.h b/test/tests.h
new file mode 100644
index 0000000..4f7795f
--- /dev/null
+++ b/test/tests.h
@@ -0,0 +1,19 @@
+/*
+ * This file is part of LibNSLayout's tests
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#ifndef nslayout_tests_h_
+#define nslayout_tests_h_
+
+#include <signal.h>
+
+#include <check.h>
+
+#include <libnslayout/nslayout.h>
+
+extern void nslayout_assert_suite(SRunner *);
+extern void nslayout_basic_layout_suite(SRunner *);
+
+#endif
commitdiff
http://git.netsurf-browser.org/libnslayout.git/commit/?id=2e86255e49f316c...
commit 2e86255e49f316c9749f350cf57d0f17a36abdaa
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add ignore file.
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..015f2f7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+build-*
+*~
commitdiff
http://git.netsurf-browser.org/libnslayout.git/commit/?id=a0ad0c682444aeb...
commit a0ad0c682444aeb8e058f846fde121f061eb17b7
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix link order.
diff --git a/Makefile b/Makefile
index beb2b46..0a84269 100644
--- a/Makefile
+++ b/Makefile
@@ -41,9 +41,9 @@ endif
ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
ifneq ($(PKGCONFIG),)
CFLAGS := $(CFLAGS) $(shell $(PKGCONFIG) \
- libwapcaplet libparserutils libcss libdom --cflags)
+ libcss libdom libwapcaplet libparserutils --cflags)
LDFLAGS := $(LDFLAGS) $(shell $(PKGCONFIG) \
- libwapcaplet libparserutils libcss libdom --libs)
+ libcss libdom libwapcaplet libparserutils --libs)
else
CFLAGS := $(CFLAGS) -I$(PREFIX)/include
LDFLAGS := $(LDFLAGS) -lparserutils -lwapcaplet -lcss -ldom
commitdiff
http://git.netsurf-browser.org/libnslayout.git/commit/?id=d01aac9ac10d902...
commit d01aac9ac10d902a799aade8270093bcba3e3a88
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix callback parameter.
diff --git a/include/libnslayout/nslayout.h b/include/libnslayout/nslayout.h
index 2a48690..f42bed7 100644
--- a/include/libnslayout/nslayout.h
+++ b/include/libnslayout/nslayout.h
@@ -130,7 +130,7 @@ nslayout_error nslayout_layout_create(
dom_document *doc,
css_select_ctx *css_ctx,
css_media_type *media,
- nslayout_callback *cb,
+ nslayout_callback cb,
void *pw,
nslayout_layout **layout);
diff --git a/src/layout.c b/src/layout.c
index dab4855..773996a 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -15,7 +15,7 @@ nslayout_error nslayout_layout_create(
dom_document *doc,
css_select_ctx *css_ctx,
css_media_type *media,
- nslayout_callback *cb,
+ nslayout_callback cb,
void *pw,
nslayout_layout **layout)
{
diff --git a/src/layout.h b/src/layout.h
index 5b43bc6..6e8f4c9 100644
--- a/src/layout.h
+++ b/src/layout.h
@@ -13,7 +13,7 @@ struct nslayout_layout {
dom_document *doc;
css_select_ctx *css_ctx;
css_media_type *media;
- nslayout_callback *cb;
+ nslayout_callback cb;
void *pw;
};
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 2 ++
Makefile | 4 +--
include/libnslayout/nslayout.h | 2 +-
src/layout.c | 2 +-
src/layout.h | 2 +-
test/Makefile | 3 ++
test/assert-tests.c | 38 ++++++++++++++++++++
test/basic-layout-tests.c | 78 ++++++++++++++++++++++++++++++++++++++++
test/tests.c | 52 +++++++++++++++++++++++++++
test/tests.h | 19 ++++++++++
10 files changed, 197 insertions(+), 5 deletions(-)
create mode 100644 .gitignore
create mode 100644 test/Makefile
create mode 100644 test/assert-tests.c
create mode 100644 test/basic-layout-tests.c
create mode 100644 test/tests.c
create mode 100644 test/tests.h
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..015f2f7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+build-*
+*~
diff --git a/Makefile b/Makefile
index beb2b46..0a84269 100644
--- a/Makefile
+++ b/Makefile
@@ -41,9 +41,9 @@ endif
ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
ifneq ($(PKGCONFIG),)
CFLAGS := $(CFLAGS) $(shell $(PKGCONFIG) \
- libwapcaplet libparserutils libcss libdom --cflags)
+ libcss libdom libwapcaplet libparserutils --cflags)
LDFLAGS := $(LDFLAGS) $(shell $(PKGCONFIG) \
- libwapcaplet libparserutils libcss libdom --libs)
+ libcss libdom libwapcaplet libparserutils --libs)
else
CFLAGS := $(CFLAGS) -I$(PREFIX)/include
LDFLAGS := $(LDFLAGS) -lparserutils -lwapcaplet -lcss -ldom
diff --git a/include/libnslayout/nslayout.h b/include/libnslayout/nslayout.h
index 2a48690..f42bed7 100644
--- a/include/libnslayout/nslayout.h
+++ b/include/libnslayout/nslayout.h
@@ -130,7 +130,7 @@ nslayout_error nslayout_layout_create(
dom_document *doc,
css_select_ctx *css_ctx,
css_media_type *media,
- nslayout_callback *cb,
+ nslayout_callback cb,
void *pw,
nslayout_layout **layout);
diff --git a/src/layout.c b/src/layout.c
index dab4855..773996a 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -15,7 +15,7 @@ nslayout_error nslayout_layout_create(
dom_document *doc,
css_select_ctx *css_ctx,
css_media_type *media,
- nslayout_callback *cb,
+ nslayout_callback cb,
void *pw,
nslayout_layout **layout)
{
diff --git a/src/layout.h b/src/layout.h
index 5b43bc6..6e8f4c9 100644
--- a/src/layout.h
+++ b/src/layout.h
@@ -13,7 +13,7 @@ struct nslayout_layout {
dom_document *doc;
css_select_ctx *css_ctx;
css_media_type *media;
- nslayout_callback *cb;
+ nslayout_callback cb;
void *pw;
};
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..5703e79
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,3 @@
+DIR_TEST_ITEMS := testrunner:tests.c;assert-tests.c;basic-layout-tests.c
+
+include $(NSBUILD)/Makefile.subdir
diff --git a/test/assert-tests.c b/test/assert-tests.c
new file mode 100644
index 0000000..4fca036
--- /dev/null
+++ b/test/assert-tests.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of LibNSLayout's tests
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include <check.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "tests.h"
+
+#ifndef UNUSED
+#define UNUSED(x) (void)(x)
+#endif
+
+/* TODO: Test for each individual param being NULL. */
+START_TEST (test_nslayout_layout_create_aborts1)
+{
+ nslayout_layout *layout;
+ (void) nslayout_layout_create(NULL, NULL, NULL, NULL, NULL, &layout);
+}
+END_TEST
+
+
+void nslayout_assert_suite(SRunner *sr)
+{
+ Suite *s = suite_create("libnslayout: API Assert tests");
+ TCase *tc_assert = tcase_create("Creation/Destruction");
+
+ tcase_add_test_raise_signal(
+ tc_assert,
+ test_nslayout_layout_create_aborts1,
+ SIGABRT);
+ suite_add_tcase(s, tc_assert);
+
+ srunner_add_suite(sr, s);
+}
diff --git a/test/basic-layout-tests.c b/test/basic-layout-tests.c
new file mode 100644
index 0000000..84611a9
--- /dev/null
+++ b/test/basic-layout-tests.c
@@ -0,0 +1,78 @@
+/*
+ * This file is part of LibNSLayout's tests
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include <check.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "tests.h"
+
+#ifndef UNUSED
+#define UNUSED(x) (void)(x)
+#endif
+
+int pw;
+
+static nslayout_error nslayout_test_callback(
+ nslayout_request *req,
+ nslayout_layout *layout,
+ void *pw)
+{
+ UNUSED(req);
+ UNUSED(layout);
+ UNUSED(pw);
+ return NSLAYOUT_OK;
+}
+
+START_TEST (test_nslayout_layout_create_ok)
+{
+ nslayout_layout *layout = NULL;
+ nslayout_error error;
+ dom_exception dom_error;
+ css_error css_err;
+ dom_document *doc;
+ css_select_ctx *css_ctx;
+ css_media_type media = CSS_MEDIA_SCREEN;
+
+ /* Create a DOM document */
+ dom_error = dom_implementation_create_document(DOM_IMPLEMENTATION_HTML,
+ NULL, NULL, NULL, NULL, NULL, &doc);
+ ck_assert(dom_error == DOM_NO_ERR);
+
+ /* Create a selection context (with no sheets added) */
+ css_err = css_select_ctx_create(&css_ctx);
+ ck_assert(css_err == CSS_OK);
+
+ error = nslayout_layout_create(doc,
+ css_ctx,
+ &media,
+ nslayout_test_callback,
+ &pw,
+ &layout);
+ fail_unless(error == NSLAYOUT_OK,
+ "Unable to create layout");
+ fail_unless(layout != NULL,
+ "Returned OK but str was still NULL");
+
+ css_err = css_select_ctx_destroy(css_ctx);
+ ck_assert(css_err == CSS_OK);
+
+ dom_node_unref(doc);
+}
+END_TEST
+
+
+void nslayout_basic_layout_suite(SRunner *sr)
+{
+ Suite *s = suite_create("libnslayout: basic layout tests");
+ TCase *tc_layout_basic = tcase_create("Creation/Destruction");
+
+ tcase_add_test(tc_layout_basic,
+ test_nslayout_layout_create_ok);
+ suite_add_tcase(s, tc_layout_basic);
+
+ srunner_add_suite(sr, s);
+}
diff --git a/test/tests.c b/test/tests.c
new file mode 100644
index 0000000..a58e038
--- /dev/null
+++ b/test/tests.c
@@ -0,0 +1,52 @@
+/*
+ * This file is part of LibNSLayout's tests
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include <check.h>
+
+#include "tests.h"
+
+#ifndef UNUSED
+#define UNUSED(x) ((x) = (x))
+#endif
+
+#ifndef NDEBUG
+/* This means that assertion failures are silent in tests */
+void __assert_fail(const char *__assertion, const char *__file,
+ unsigned int __line, const char *__function) {
+ (void)__assertion;
+ (void)__file;
+ (void)__line;
+ (void)__function;
+ abort();
+}
+#endif
+
+int main(int argc, char **argv)
+{
+ int number_failed = 0;
+ SRunner *sr;
+
+ UNUSED(argc);
+ UNUSED(argv);
+
+ sr = srunner_create(suite_create("Test suite for libnslayout"));
+
+#ifndef NDEBUG
+ nslayout_assert_suite(sr);
+#endif
+ nslayout_basic_layout_suite(sr);
+
+ srunner_set_fork_status(sr, CK_FORK);
+ srunner_run_all(sr, CK_ENV);
+ number_failed = srunner_ntests_failed(sr);
+
+ srunner_free(sr);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/test/tests.h b/test/tests.h
new file mode 100644
index 0000000..4f7795f
--- /dev/null
+++ b/test/tests.h
@@ -0,0 +1,19 @@
+/*
+ * This file is part of LibNSLayout's tests
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#ifndef nslayout_tests_h_
+#define nslayout_tests_h_
+
+#include <signal.h>
+
+#include <check.h>
+
+#include <libnslayout/nslayout.h>
+
+extern void nslayout_assert_suite(SRunner *);
+extern void nslayout_basic_layout_suite(SRunner *);
+
+#endif
--
NetSurf Layout Engine