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