diff --git a/tests/mimehandler.c b/tests/mimehandler.c new file mode 100644 index 0000000..78e57b5 --- /dev/null +++ b/tests/mimehandler.c @@ -0,0 +1,60 @@ +/* $Id$ */ +/* Copyright (c) 2017 Pierre Pronchery */ +/* This file is part of DeforaOS libDesktop */ +/* All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + + + +#include +#include +#include +#include "../src/mimehandler.c" + + +/* main */ +int main(void) +{ + MimeHandler * handler; + char * path; + + if((path = getcwd(NULL, 0)) == NULL) + return 2; + if(setenv("XDG_DATA_HOME", path, 1) != 0) + { + free(path); + return 3; + } + free(path); + if((handler = mimehandler_new_load("Root")) == NULL) + return 4; + if(mimehandler_get_type(handler) != MIME_HANDLER_TYPE_DIRECTORY) + { + mimehandler_delete(handler); + return 5; + } + mimehandler_delete(handler); + return 0; +} diff --git a/tests/project.conf b/tests/project.conf index bbc7f30..f135db3 100644 --- a/tests/project.conf +++ b/tests/project.conf @@ -1,4 +1,4 @@ -targets=htmllint.log,tests.log,widget,xmllint.log +targets=htmllint.log,mimehandler,tests.log,widget,xmllint.log cppflags_force=-I ../include cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector-all ldflags=-pie -Wl,-z,relro -Wl,-z,now @@ -8,17 +8,25 @@ ldflags_force=`pkg-config --libs libSystem gtk+-2.0` $(OBJDIR)../src/libDesktop. #for Gtk+ 3 #cflags_force=`pkg-config --cflags libSystem gtk+-3.0` #ldflags_force=`pkg-config --libs libSystem gtk+-3.0` $(OBJDIR)../src/libDesktop.a -dist=Makefile,htmllint.sh,pkgconfig.sh,tests.sh,xmllint.sh +dist=Makefile,applications/Root.desktop,htmllint.sh,pkgconfig.sh,tests.sh,xmllint.sh [htmllint.log] type=script script=./htmllint.sh depends=htmllint.sh +[mimehandler] +type=binary +sources=mimehandler.c +depends=applications/Root.desktop + +[mimehandler.c] +depends=../src/mimehandler.c + [tests.log] type=script script=./tests.sh -depends=pkgconfig.sh,tests.sh +depends=$(OBJDIR)mimehandler$(EXEEXT),pkgconfig.sh,tests.sh [widget] type=binary diff --git a/tests/tests.sh b/tests/tests.sh index 9945670..6e04a26 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -109,7 +109,7 @@ target="$1" [ "$clean" -ne 0 ] && exit 0 -tests="pkgconfig.sh" +tests="mimehandler pkgconfig.sh" failures= $DATE > "$target"