diff --git a/build/VS2012/LCUI-Demo.sln b/build/VS2012/LCUI-Demo.sln index db5a66d0..ab665613 100644 --- a/build/VS2012/LCUI-Demo.sln +++ b/build/VS2012/LCUI-Demo.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "helloworld", "helloworld\helloworld.vcxproj", "{125F6442-33EA-428E-B75B-9F99FB73D077}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LCUITest", "LCUITest\LCUITest.vcxproj", "{D639E1FA-B41B-40E5-8EC8-6FA3E5D946E7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -23,6 +25,14 @@ Global {125F6442-33EA-428E-B75B-9F99FB73D077}.Release|Win32.ActiveCfg = Release|Win32 {125F6442-33EA-428E-B75B-9F99FB73D077}.Release|Win32.Build.0 = Release|Win32 {125F6442-33EA-428E-B75B-9F99FB73D077}.Release|x64.ActiveCfg = Release|Win32 + {D639E1FA-B41B-40E5-8EC8-6FA3E5D946E7}.Debug|ARM.ActiveCfg = Debug|Win32 + {D639E1FA-B41B-40E5-8EC8-6FA3E5D946E7}.Debug|Win32.ActiveCfg = Debug|Win32 + {D639E1FA-B41B-40E5-8EC8-6FA3E5D946E7}.Debug|Win32.Build.0 = Debug|Win32 + {D639E1FA-B41B-40E5-8EC8-6FA3E5D946E7}.Debug|x64.ActiveCfg = Debug|Win32 + {D639E1FA-B41B-40E5-8EC8-6FA3E5D946E7}.Release|ARM.ActiveCfg = Release|Win32 + {D639E1FA-B41B-40E5-8EC8-6FA3E5D946E7}.Release|Win32.ActiveCfg = Release|Win32 + {D639E1FA-B41B-40E5-8EC8-6FA3E5D946E7}.Release|Win32.Build.0 = Release|Win32 + {D639E1FA-B41B-40E5-8EC8-6FA3E5D946E7}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/test.c b/test/test.c new file mode 100644 index 00000000..380691de --- /dev/null +++ b/test/test.c @@ -0,0 +1,38 @@ +#include +#include +#include "test.h" + +#ifdef LCUI_BUILD_IN_WIN32 +#include +#include + +static void InitConsoleWindow( void ) +{ + int hCrt; + FILE *hf; + AllocConsole(); + hCrt = _open_osfhandle( (long)GetStdHandle( STD_OUTPUT_HANDLE ), _O_TEXT ); + hf = _fdopen( hCrt, "w" ); + *stdout = *hf; + setvbuf( stdout, NULL, _IONBF, 0 ); + // test code + printf( "InitConsoleWindow OK!\n" ); +} + +#endif + +int main(void) +{ + int ret = 0; +#ifdef LCUI_BUILD_IN_WIN32 + _wchdir( L"../test/" ); + InitConsoleWindow(); +#endif + LCUI_Init(); + ret += TestCSSParser(); + printf("test result code: %d\n", ret); +#ifdef LCUI_BUILD_IN_WIN32 + system("pause"); +#endif + return ret; +} diff --git a/test/test.h b/test/test.h new file mode 100644 index 00000000..70454b56 --- /dev/null +++ b/test/test.h @@ -0,0 +1,3 @@ + +/** 测试CSS解析器 */ +int TestCSSParser( void ); diff --git a/test/test_css_parser.c b/test/test_css_parser.c new file mode 100644 index 00000000..fdb74179 --- /dev/null +++ b/test/test_css_parser.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include + +#define assert(X) if(!(X)) {return -1;} + +int TestCSSParser(void) +{ + LCUI_Widget box, btn, text; + box = LCUIBuilder_LoadFile( "test_css_parser.xml" ); + if( !box ) { + return -1; + } + text = LCUIWidget_GetById( "test-textview" ); + Widget_Update( text, TRUE ); + Widget_Flush( text ); + 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" ); + Widget_Update( btn, TRUE ); + Widget_Update( text, TRUE ); + Widget_Flush( text ); + assert( text->style->sheet[key_background_color].val_color.value == 0xffff0000 ); + assert( text->style->sheet[key_background_size].val_style == SV_CONTAIN ); + return 0; +} diff --git a/test/test_css_parser.css b/test/test_css_parser.css new file mode 100644 index 00000000..661e07d7 --- /dev/null +++ b/test/test_css_parser.css @@ -0,0 +1,21 @@ +.window .content .btn textview { + width: 100px; +} +.window .content .btn .test { + height: 60px; +} +.window textview { + position: absolute; +} +#test-textview { + top: 12px; +} +.text { + left: 20px; +} +.btn:hover textview { + background-color: #f00; +} +.btn:hover .text { + background-size: contain; +} diff --git a/test/test_css_parser.xml b/test/test_css_parser.xml new file mode 100644 index 00000000..5b9e652a --- /dev/null +++ b/test/test_css_parser.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +