tests/plover-gtk/test-stockicons.c
author J. Ali Harlow <ali@juiblex.co.uk>
Thu Jul 16 19:54:45 2020 +0100 (2020-07-16)
changeset 99 0121592e2512
permissions -rw-r--r--
Fix most compiler warnings
     1 /*
     2  * Copyright (C) 2016  J. Ali Harlow <ali@juiblex.co.uk>
     3  *
     4  * This program is free software; you can redistribute it and/or modify
     5  * it under the terms of the GNU General Public License as published by
     6  * the Free Software Foundation; either version 2 of the License, or
     7  * (at your option) any later version.
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License along
    15  * with this program; if not, write to the Free Software Foundation, Inc.,
    16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    17  */
    18 
    19 #include <stdlib.h>
    20 #include <string.h>
    21 #include <glib.h>
    22 #include <gdk/gdk.h>
    23 #include <gtk/gtk.h>
    24 #include <plover-gtk/stockicons.h>
    25 
    26 static void test_basic(void)
    27 {
    28     gchar *cwd;
    29     cwd=g_get_current_dir();
    30     g_setenv("PLOVER_ICONS_DATADIR",cwd,TRUE);
    31     g_free(cwd);
    32     plover_icons_add_to_stock("mimetypes",
    33       "application-x-redhat-package-manager");
    34     g_assert(gtk_icon_factory_lookup_default("application-x-redhat-package-manager"));
    35     g_unsetenv("PLOVER_ICONS_DATADIR");
    36 }
    37 
    38 static void test_no_svg(void)
    39 {
    40     gchar *cwd;
    41     cwd=g_get_current_dir();
    42     g_setenv("PLOVER_ICONS_DATADIR",cwd,TRUE);
    43     g_free(cwd);
    44     g_setenv("PLOVER_IGNORE_SVG_SUPPORT","yes",TRUE);
    45     plover_icons_add_to_stock("mimetypes",
    46       "application-x-redhat-package-manager");
    47     g_assert(gtk_icon_factory_lookup_default("application-x-redhat-package-manager"));
    48     g_unsetenv("PLOVER_IGNORE_SVG_SUPPORT");
    49     g_unsetenv("PLOVER_ICONS_DATADIR");
    50 }
    51 
    52 static void test_none_existant(void)
    53 {
    54     plover_icons_add_to_stock("mimetypes",
    55       "application-x-plover-test-stockicons");
    56 }
    57 
    58 int main(int argc,char **argv)
    59 {
    60     int retval;
    61     gtk_test_init(&argc,&argv,NULL);
    62     g_test_bug_base("mailto:ali@juiblex.co.uk");
    63     g_test_add_func("/stockicons/basic",test_basic);
    64     g_test_add_func("/stockicons/no-svg",test_no_svg);
    65     g_test_add_func("/stockicons/non-existant",test_none_existant);
    66     retval=g_test_run();
    67     return retval;
    68 }