1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/plover-gtk/test-stockicons.c Thu Jul 16 23:02:31 2020 +0100
1.3 @@ -0,0 +1,68 @@
1.4 +/*
1.5 + * Copyright (C) 2016 J. Ali Harlow <ali@juiblex.co.uk>
1.6 + *
1.7 + * This program is free software; you can redistribute it and/or modify
1.8 + * it under the terms of the GNU General Public License as published by
1.9 + * the Free Software Foundation; either version 2 of the License, or
1.10 + * (at your option) any later version.
1.11 + *
1.12 + * This program is distributed in the hope that it will be useful,
1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 + * GNU General Public License for more details.
1.16 + *
1.17 + * You should have received a copy of the GNU General Public License along
1.18 + * with this program; if not, write to the Free Software Foundation, Inc.,
1.19 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1.20 + */
1.21 +
1.22 +#include <stdlib.h>
1.23 +#include <string.h>
1.24 +#include <glib.h>
1.25 +#include <gdk/gdk.h>
1.26 +#include <gtk/gtk.h>
1.27 +#include <plover-gtk/stockicons.h>
1.28 +
1.29 +static void test_basic(void)
1.30 +{
1.31 + gchar *cwd;
1.32 + cwd=g_get_current_dir();
1.33 + g_setenv("PLOVER_ICONS_DATADIR",cwd,TRUE);
1.34 + g_free(cwd);
1.35 + plover_icons_add_to_stock("mimetypes",
1.36 + "application-x-redhat-package-manager");
1.37 + g_assert(gtk_icon_factory_lookup_default("application-x-redhat-package-manager"));
1.38 + g_unsetenv("PLOVER_ICONS_DATADIR");
1.39 +}
1.40 +
1.41 +static void test_no_svg(void)
1.42 +{
1.43 + gchar *cwd;
1.44 + cwd=g_get_current_dir();
1.45 + g_setenv("PLOVER_ICONS_DATADIR",cwd,TRUE);
1.46 + g_free(cwd);
1.47 + g_setenv("PLOVER_IGNORE_SVG_SUPPORT","yes",TRUE);
1.48 + plover_icons_add_to_stock("mimetypes",
1.49 + "application-x-redhat-package-manager");
1.50 + g_assert(gtk_icon_factory_lookup_default("application-x-redhat-package-manager"));
1.51 + g_unsetenv("PLOVER_IGNORE_SVG_SUPPORT");
1.52 + g_unsetenv("PLOVER_ICONS_DATADIR");
1.53 +}
1.54 +
1.55 +static void test_none_existant(void)
1.56 +{
1.57 + plover_icons_add_to_stock("mimetypes",
1.58 + "application-x-plover-test-stockicons");
1.59 +}
1.60 +
1.61 +int main(int argc,char **argv)
1.62 +{
1.63 + int retval;
1.64 + gtk_test_init(&argc,&argv,NULL);
1.65 + g_test_bug_base("mailto:ali@juiblex.co.uk");
1.66 + g_test_add_func("/stockicons/basic",test_basic);
1.67 + g_test_add_func("/stockicons/no-svg",test_no_svg);
1.68 + g_test_add_func("/stockicons/non-existant",test_none_existant);
1.69 + retval=g_test_run();
1.70 + return retval;
1.71 +}