2016-11-20 18:27:11 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <LCUI_Build.h>
|
2016-01-17 22:40:09 +08:00
|
|
|
#include <LCUI/LCUI.h>
|
|
|
|
|
#include <LCUI/display.h>
|
|
|
|
|
#include <LCUI/gui/builder.h>
|
2016-11-20 18:27:11 +08:00
|
|
|
#include "test.h"
|
2016-01-17 22:40:09 +08:00
|
|
|
|
2016-11-20 18:27:11 +08:00
|
|
|
int test_css_parser( void )
|
2016-01-17 22:40:09 +08:00
|
|
|
{
|
|
|
|
|
LCUI_Widget box, btn, text;
|
2016-11-20 18:27:11 +08:00
|
|
|
|
|
|
|
|
LCUI_Init();
|
2016-01-17 22:40:09 +08:00
|
|
|
box = LCUIBuilder_LoadFile( "test_css_parser.xml" );
|
|
|
|
|
if( !box ) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
text = LCUIWidget_GetById( "test-textview" );
|
2016-01-21 14:13:16 +08:00
|
|
|
Widget_UpdateStyle( text, TRUE );
|
2016-05-16 15:48:39 +08:00
|
|
|
Widget_Update( text );
|
2016-11-20 18:27:11 +08:00
|
|
|
LCUI_PrintCSSLibrary();
|
|
|
|
|
printf( "test widget style: {\n" );
|
|
|
|
|
LCUI_PrintStyleSheet( text->style );
|
|
|
|
|
printf( "}\n" );
|
2016-01-17 22:40:09 +08:00
|
|
|
assert( text->style->sheet[key_width].val_px == 100 );
|
|
|
|
|
assert( text->style->sheet[key_height].val_px == 60 );
|
|
|
|
|
assert( text->style->sheet[key_position].val_style == SV_ABSOLUTE );
|
|
|
|
|
assert( text->style->sheet[key_top].val_px == 12 );
|
|
|
|
|
assert( text->style->sheet[key_left].val_px == 20 );
|
|
|
|
|
btn = LCUIWidget_GetById( "test-btn" );
|
|
|
|
|
Widget_AddStatus( btn, "hover" );
|
2016-01-21 14:13:16 +08:00
|
|
|
Widget_UpdateStyle( btn, TRUE );
|
|
|
|
|
Widget_UpdateStyle( text, TRUE );
|
2016-05-16 15:48:39 +08:00
|
|
|
Widget_Update( text );
|
2016-01-17 22:40:09 +08:00
|
|
|
assert( text->style->sheet[key_background_color].val_color.value == 0xffff0000 );
|
|
|
|
|
assert( text->style->sheet[key_background_size].val_style == SV_CONTAIN );
|
2016-11-20 18:27:11 +08:00
|
|
|
LCUI_Destroy();
|
2016-01-17 22:40:09 +08:00
|
|
|
return 0;
|
|
|
|
|
}
|