PageRenderTime 21ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/theme_test.c

http://ftk.googlecode.com/
C | 52 lines | 46 code | 6 blank | 0 comment | 11 complexity | 3561b1616b9e94cf52a14be7eb1701bf MD5 | raw file
 1#include "ftk.h"
 2#include "ftk_theme.h"
 3
 4const char* xml = "\
 5<theme name=\"android\" >\
 6<entry bg[normal]=\"ff00ffff\" \
 7	bg[focused]=\"ff01ffff\" \
 8	bg[active]=\"ff02ffff\" \
 9	bg[disable]=\"ff03a899\" \
10	bg_image[normal]=\"Acrobat.png\" \
11	bg_image[focused]=\"Chat.png\" \
12	bg_image[active]=\"Flickr.png\" \
13	bg_image[disable]=\"Flickr.png\"\
14	fg_image[normal]=\"fAcrobat.png\" \
15	fg_image[focused]=\"fChat.png\" \
16	fg_image[active]=\"fFlickr.png\" \
17	fg_image[disable]=\"fFlickr.png\"\
18	fg[normal]=\"ff000000\" \
19	fg[focused]=\"ff010000\" \
20	fg[active]=\"ff020000\" \
21	fg[disable]=\"ff030000\" \
22	bd[normal]=\"ff000000\" \
23	bd[focused]=\"ff010000\"\
24	bd[active]=\"ff020000\" \
25	bd[disable]=\"ff030000\" />\
26</theme>";
27
28int main(int argc, char* argv[])
29{
30	FtkColor c = {0};
31	FtkTheme* thiz = NULL;
32	FtkWidgetState state = FTK_WIDGET_NORMAL;
33	FtkWidgetType type = FTK_ENTRY;
34	
35	ftk_set_allocator(ftk_allocator_default_create());
36	thiz = ftk_theme_create(0);
37	assert(ftk_theme_parse_data(thiz, xml, strlen(xml)) == RET_OK);
38
39	for(; state < FTK_WIDGET_STATE_NR; state++)
40	{
41		c = ftk_theme_get_bg_color(thiz, type, state);
42		assert(c.a == 0xff && c.r == state);
43		c = ftk_theme_get_fg_color(thiz, type, state);
44		assert(c.a == 0xff && c.r == state);
45		c = ftk_theme_get_border_color(thiz, type, state);
46		assert(c.a == 0xff && c.r == state);
47	}
48
49	ftk_theme_destroy(thiz);
50
51	return 0;
52}