Commit eefba20b authored by Moritz Lipp's avatar Moritz Lipp

Save page in annotation and render annotation

parent 26ff0310
Pipeline #66 passed with stage
......@@ -6,19 +6,33 @@
#include "annotations.h"
#include "annotations/internal.h"
#include "internal.h"
#define CHECK_IF_IMPLEMENTED(annotation, function) \
if ((annotation)->page == NULL || \
(annotation)->page->document == NULL || \
(annotation)->page->document->plugin == NULL || \
(annotation)->page->document->plugin->functions.function == NULL) { \
return ZATHURA_ERROR_PLUGIN_NOT_IMPLEMENTED; \
}
zathura_error_t
zathura_annotation_new(zathura_annotation_t** annotation, zathura_annotation_type_t type)
zathura_annotation_new(zathura_page_t* page, zathura_annotation_t** annotation, zathura_annotation_type_t type)
{
if (annotation == NULL) {
if (page == NULL || annotation == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
/* Create annotation */
*annotation = calloc(1, sizeof(**annotation));
if (*annotation == NULL) {
return ZATHURA_ERROR_OUT_OF_MEMORY;
}
/* Save page */
(*annotation)->page = page;
/* Set type */
switch (type) {
case ZATHURA_ANNOTATION_UNKNOWN:
case ZATHURA_ANNOTATION_TEXT:
......@@ -422,3 +436,72 @@ zathura_annotation_get_color(zathura_annotation_t* annotation,
return ZATHURA_ERROR_OK;
}
zathura_error_t
zathura_annotation_get_page(zathura_annotation_t* annotation,
zathura_page_t** page)
{
if (annotation == NULL || page == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
*page = annotation->page;
return ZATHURA_ERROR_OK;
}
zathura_error_t
zathura_annotation_set_user_data(zathura_annotation_t*
annotation, void* data, zathura_free_function_t free_function)
{
if (annotation == NULL || data == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
if (annotation->user_data != NULL && annotation->user_data_free_function) {
annotation->user_data_free_function(annotation->user_data);
}
annotation->user_data = data;
annotation->user_data_free_function = free_function;
return ZATHURA_ERROR_OK;
}
zathura_error_t
zathura_annotation_get_user_data(zathura_annotation_t* annotation, void** user_data)
{
if (annotation == NULL || user_data == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
*user_data = annotation->user_data;
return ZATHURA_ERROR_OK;
}
zathura_error_t
zathura_annotation_render(zathura_annotation_t* annotation,
zathura_image_buffer_t** buffer, double scale)
{
if (annotation == NULL || buffer == NULL || scale <= 0.0) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
CHECK_IF_IMPLEMENTED(annotation, annotation_render)
return annotation->page->document->plugin->functions.annotation_render(annotation, buffer, scale);
}
zathura_error_t
zathura_annotation_render_cairo(zathura_annotation_t* annotation, cairo_t*
cairo, double scale)
{
if (annotation == NULL || cairo == NULL || scale <= 0.0) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
CHECK_IF_IMPLEMENTED(annotation, annotation_render_cairo)
return annotation->page->document->plugin->functions.annotation_render_cairo(annotation, cairo, scale);
}
......@@ -181,6 +181,7 @@ typedef enum zathura_annotation_type_s {
/**
* Creates a new annotation of the specified type
*
* @param[in] page The page that is associated with this annotation
* @param[out] annotation The annotation
* @param[in] type The type of the annotation
*
......@@ -189,7 +190,7 @@ typedef enum zathura_annotation_type_s {
* @return ZATHURA_ERROR_ANNOTATION_INVALID_TYPE Mismatching type of annotation passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_new(zathura_annotation_t** annotation,
zathura_error_t zathura_annotation_new(zathura_page_t* page, zathura_annotation_t** annotation,
zathura_annotation_type_t type);
/**
......@@ -385,7 +386,7 @@ zathura_error_t zathura_annotation_set_color(zathura_annotation_t* annotation,
* - The border of a link annotation
*
* @param[in] annotation The annotation
* @param[in] color The color
* @param[out] color The color
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
......@@ -394,6 +395,49 @@ zathura_error_t zathura_annotation_set_color(zathura_annotation_t* annotation,
zathura_error_t zathura_annotation_get_color(zathura_annotation_t* annotation,
zathura_annotation_color_t* color);
/**
* Returns the page associated with this annotation
*
* @param[in] annotation The annotation
* @param[out] page The associated page
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_get_page(zathura_annotation_t* annotation,
zathura_page_t** page);
/**
* Renders the annotation to a @a ::zathura_image_buffer_t image buffer
*
* @param[in] annotation The used annotation object
* @param[out] buffer The image buffer
* @param[in] scale Scale level
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_render(zathura_annotation_t* annotation,
zathura_image_buffer_t** buffer, double scale);
#ifdef HAVE_CAIRO
/**
* Renders the annotation to a cairo object
*
* @param[in] annotation The used annotation object
* @param[out] cairo The cairo object
* @param[in] scale Scale level
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_render_cairo(zathura_annotation_t* annotation, cairo_t* cairo,
double scale);
#endif
#include "annotations/annotation-3d.h"
#include "annotations/annotation-caret.h"
#include "annotations/annotation-circle.h"
......
......@@ -23,6 +23,11 @@ struct zathura_annotation_s {
*/
zathura_rectangle_t position;
/**
* The associated page object
*/
zathura_page_t* page;
/**
* Text to be displayed for the annotation or, if this type of annotation does
* not display text, an alternate description of the annotation’s contents in
......@@ -164,6 +169,16 @@ struct zathura_annotation_s {
*/
struct zathura_annotation_widget_s* widget;
} data;
/**
* User data
*/
void* user_data;
/**
* User data free function
*/
zathura_free_function_t user_data_free_function;
};
#include "internal/annotation-3d.h"
......
......@@ -71,8 +71,14 @@ typedef zathura_error_t (*zathura_plugin_page_render_t)(zathura_page_t* page, za
#ifdef HAVE_CAIRO
typedef zathura_error_t (*zathura_plugin_page_render_cairo_t)(zathura_page_t* page, cairo_t* cairo, double scale, int rotation, int flags);
#endif
typedef zathura_error_t (*zathura_plugin_form_field_save_t)(zathura_form_field_t* form_field);
typedef zathura_error_t (*zathura_plugin_annotation_render_t)(zathura_annotation_t* annotation, zathura_image_buffer_t** buffer, double scale);
#ifdef HAVE_CAIRO
typedef zathura_error_t (*zathura_plugin_annotation_render_cairo_t)(zathura_annotation_t* annotation, cairo_t* cairo, double scale);
#endif
struct zathura_plugin_functions_s {
zathura_plugin_document_open_t document_open;
zathura_plugin_document_free_t document_free;
......@@ -96,12 +102,18 @@ struct zathura_plugin_functions_s {
#endif
zathura_plugin_form_field_save_t form_field_save;
zathura_plugin_annotation_render_t annotation_render;
#ifdef HAVE_CAIRO
zathura_plugin_annotation_render_cairo_t annotation_render_cairo;
#endif
};
zathura_error_t zathura_plugin_set_name(zathura_plugin_t* plugin, const char* name);
zathura_error_t zathura_plugin_set_register_function(zathura_plugin_t* plugin, zathura_plugin_register_function_t function);
zathura_error_t zathura_plugin_add_mimetype(zathura_plugin_t* plugin, const char* mime_type);
#include "plugin-api/annotations.h"
#include "plugin-api/attachment.h"
#include "plugin-api/document.h"
#include "plugin-api/form-fields.h"
......
/* See LICENSE file for license and copyright information */
#ifndef LIBZATHURA_PLUGIN_API_ANNOTATIONS_H
#define LIBZATHURA_PLUGIN_API_ANNOTATIONS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../error.h"
#include "../annotations.h"
/**
* Sets the custom data of an annotation object
*
* @param[in] annotation The annotation object
* @param[in] data The custom data
* @param[in] free_function Free function for the custom data
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_set_user_data(zathura_annotation_t*
annotation, void* data, zathura_free_function_t free_function);
/**
* Returns the custom data of an annotation object
*
* @param[in] annotation The annotation object
* @param[out] data The custom data
*
* @return ZATHURA_ERROR_OK No error occurred
* @return ZATHURA_ERROR_INVALID_ARGUMENTS Invalid arguments have been passed
* @return ZATHURA_ERROR_UNKNOWN An unspecified error occurred
*/
zathura_error_t zathura_annotation_get_user_data(zathura_annotation_t* annotation, void** data);
#ifdef __cplusplus
}
#endif
#endif /* PLUGIN_API_ANNOTATIONS_H */
......@@ -9,6 +9,7 @@ extern "C" {
#include "../error.h"
#include "../form-fields.h"
#include "../page.h"
/**
* Creates a new form field of the given type.
......
......@@ -7,18 +7,35 @@
#include "annotations.h"
#include "annotations/internal.h"
#include "plugin-api.h"
#include "utils.h"
static zathura_annotation_t* annotation = NULL;
zathura_page_t* page;
zathura_document_t* document;
zathura_plugin_manager_t* plugin_manager;
static void setup(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_CARET) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_CARET) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
static void teardown(void) {
if (annotation != NULL) {
fail_unless(zathura_annotation_free(annotation) == ZATHURA_ERROR_OK);
annotation = NULL;
}
fail_unless(zathura_document_free(document) == ZATHURA_ERROR_OK);
document = NULL;
fail_unless(zathura_plugin_manager_free(plugin_manager) == ZATHURA_ERROR_OK);
plugin_manager = NULL;
}
START_TEST(test_annotation_free) {
......@@ -35,17 +52,19 @@ START_TEST(test_annotation_new) {
zathura_annotation_t* test_annotation;
/* invalid arguments */
fail_unless(zathura_annotation_new(NULL, 0) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_new(&test_annotation, INT_MAX) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_new(NULL, NULL, 0) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_new(NULL, &test_annotation, INT_MAX) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_new(page, NULL, 0) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_new(page, &test_annotation, INT_MAX) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_new(&test_annotation,
fail_unless(zathura_annotation_new(page, &test_annotation,
ZATHURA_ANNOTATION_UNKNOWN) == ZATHURA_ERROR_OK);
fail_unless(zathura_annotation_free(test_annotation) == ZATHURA_ERROR_OK);
/* fault injection */
fiu_enable("libc/mm/calloc", 1, NULL, 0);
fail_unless(zathura_annotation_new(&test_annotation, ZATHURA_PAGE_TRANSITION_SPLIT) == ZATHURA_ERROR_OUT_OF_MEMORY);
fail_unless(zathura_annotation_new(page, &test_annotation, ZATHURA_PAGE_TRANSITION_SPLIT) == ZATHURA_ERROR_OUT_OF_MEMORY);
fiu_disable("libc/mm/calloc");
} END_TEST
......@@ -222,6 +241,90 @@ START_TEST(test_annotation_get_color) {
fail_unless(zathura_annotation_get_color(annotation, &color) == ZATHURA_ERROR_OK);
} END_TEST
START_TEST(test_annotation_get_page) {
zathura_page_t* ppage;
/* invalid arguments */
fail_unless(zathura_annotation_get_page(NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_get_page(annotation, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_get_page(NULL, &ppage) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_get_page(annotation, &ppage) == ZATHURA_ERROR_OK);
fail_unless(page == ppage);
} END_TEST
START_TEST(test_annotation_render) {
zathura_image_buffer_t* buffer;
/* basic invalid arguments */
fail_unless(zathura_annotation_render(NULL, NULL, 0) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_render(annotation, NULL, 0) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_render(annotation, &buffer, -1) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_render(annotation, &buffer, 1.0) == ZATHURA_ERROR_OK);
} END_TEST
#ifdef HAVE_CAIRO
START_TEST(test_annotation_render_cairo) {
cairo_t* cairo = (cairo_t*) 0xCAFEBABE;
/* basic invalid arguments */
fail_unless(zathura_annotation_render_cairo(NULL, NULL, 0) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_render_cairo(annotation, NULL, 0) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_render_cairo(annotation, cairo, -1) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_render_cairo(annotation, cairo, 1.0) == ZATHURA_ERROR_OK);
} END_TEST
#endif
START_TEST(test_annotation_set_user_data) {
void* user_data;
/* invalid arguments */
fail_unless(zathura_annotation_set_user_data(NULL, NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_set_user_data(annotation, NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_set_user_data(NULL, &user_data, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_set_user_data(annotation, &user_data, NULL) == ZATHURA_ERROR_OK);
} END_TEST
static void annotation_free_function(void* data) {
fail_unless(data == (void*) 0xCAFEBABE);
}
START_TEST(test_annotation_set_user_data_free_function) {
void* user_data = (void*) 0xCAFEBABE;
zathura_annotation_t* annotation;
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_UNKNOWN) == ZATHURA_ERROR_OK);
fail_unless(zathura_annotation_set_user_data(annotation, user_data, annotation_free_function) == ZATHURA_ERROR_OK);
/* valid arguments */
fail_unless(zathura_annotation_set_user_data(annotation, user_data, NULL) == ZATHURA_ERROR_OK);
fail_unless(zathura_annotation_free(annotation) == ZATHURA_ERROR_OK);
} END_TEST
START_TEST(test_annotation_get_user_data) {
void* user_data = (void*) 0xCAFEBABE;
/* invalid arguments */
fail_unless(zathura_annotation_get_user_data(NULL, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_get_user_data(annotation, NULL) == ZATHURA_ERROR_INVALID_ARGUMENTS);
fail_unless(zathura_annotation_get_user_data(NULL, &user_data) == ZATHURA_ERROR_INVALID_ARGUMENTS);
/* valid arguments */
fail_unless(zathura_annotation_set_user_data(annotation, user_data, NULL) == ZATHURA_ERROR_OK);
void* user_data2;
fail_unless(zathura_annotation_get_user_data(annotation, &user_data2) == ZATHURA_ERROR_OK);
fail_unless(user_data == user_data2);
} END_TEST
#include "annotations/annotation-3d.c"
#include "annotations/annotation-caret.c"
#include "annotations/annotation-circle.c"
......@@ -273,6 +376,12 @@ suite_annotations(void)
tcase_add_test(tcase, test_annotation_get_flags);
tcase_add_test(tcase, test_annotation_set_color);
tcase_add_test(tcase, test_annotation_get_color);
tcase_add_test(tcase, test_annotation_get_page);
tcase_add_test(tcase, test_annotation_render);
tcase_add_test(tcase, test_annotation_render_cairo);
tcase_add_test(tcase, test_annotation_set_user_data);
tcase_add_test(tcase, test_annotation_set_user_data_free_function);
tcase_add_test(tcase, test_annotation_get_user_data);
suite_add_tcase(suite, tcase);
tcase = tcase_create("text");
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_3d(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_3D) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_3D) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -6,7 +6,12 @@
#include "annotations.h"
static void setup_annotation_caret(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_CARET) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_CARET) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_circle(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_CIRCLE) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_CIRCLE) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -7,7 +7,12 @@
#include "annotations.h"
static void setup_annotation_file(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_FILE_ATTACHMENT) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_FILE_ATTACHMENT) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -6,7 +6,12 @@
#include "annotations.h"
static void setup_annotation_free_text(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_FREE_TEXT) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_FREE_TEXT) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_highlight(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_HIGHLIGHT) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_HIGHLIGHT) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_ink(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_INK) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_INK) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_line(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_LINE) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_LINE) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_link(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_LINK) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_LINK) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -7,7 +7,12 @@
#include "annotations/internal.h"
static void setup_annotation_markup(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_TEXT) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_TEXT) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......@@ -41,7 +46,7 @@ START_TEST(test_annotation_is_markup_annotation) {
bool is_markup_annotation;
/* setup */
fail_unless(zathura_annotation_new(&markup_annotation, ZATHURA_ANNOTATION_TEXT)
fail_unless(zathura_annotation_new(page, &markup_annotation, ZATHURA_ANNOTATION_TEXT)
== ZATHURA_ERROR_OK);
/* invalid arguments */
......@@ -62,7 +67,7 @@ START_TEST(test_annotation_is_markup_annotation) {
/* valid arguments */
#define TEST_IS_MARKUP_ANNOTATION(type, result) \
fail_unless(zathura_annotation_new(&markup_annotation, (type)) \
fail_unless(zathura_annotation_new(page, &markup_annotation, (type)) \
== ZATHURA_ERROR_OK); \
fail_unless(markup_annotation != NULL); \
fail_unless(zathura_annotation_is_markup_annotation(markup_annotation, &is_markup_annotation) \
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_movie(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_MOVIE) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_MOVIE) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_polygon(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_POLYGON) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_POLYGON) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_poly_line(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_POLY_LINE) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_POLY_LINE) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_popup(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_POPUP) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_POPUP) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_printer_mark(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_PRINTER_MARK) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_PRINTER_MARK) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_screen(void) {
fail_unless(zathura_annotation_new(&annotation, ZATHURA_ANNOTATION_SCREEN) == ZATHURA_ERROR_OK);
setup_document_plugin(&plugin_manager, &document);
fail_unless(zathura_document_get_page(document, 0, &page) == ZATHURA_ERROR_OK);
fail_unless(page != NULL);
fail_unless(zathura_annotation_new(page, &annotation, ZATHURA_ANNOTATION_SCREEN) == ZATHURA_ERROR_OK);
fail_unless(annotation != NULL);
}
......
......@@ -5,7 +5,12 @@
#include "annotations.h"
static void setup_annotation_sound(void) {
fail_unless(