From 7483cbb904be6f08c00360f57774eca8abb071f3 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sat, 25 Feb 2017 22:12:08 +0000 Subject: [PATCH] [COMCTL32] -Test BCM_SETTEXTMARGIN, BCM_SETIMAGELIST, BCM_GETIMAGELIST and BCM_GETTEXTMARGIN for the v6 button. svn path=/trunk/; revision=73912 --- rostests/apitests/CMakeLists.txt | 1 + rostests/apitests/comctl32/CMakeLists.txt | 6 ++ rostests/apitests/comctl32/button.c | 90 +++++++++++++++++++ .../apitests/comctl32/comctl32_apitest.rc | 7 ++ rostests/apitests/comctl32/testlist.c | 10 +++ 5 files changed, 114 insertions(+) create mode 100644 rostests/apitests/comctl32/CMakeLists.txt create mode 100644 rostests/apitests/comctl32/button.c create mode 100644 rostests/apitests/comctl32/comctl32_apitest.rc create mode 100644 rostests/apitests/comctl32/testlist.c diff --git a/rostests/apitests/CMakeLists.txt b/rostests/apitests/CMakeLists.txt index e43ca4f87d3..f240b57731e 100644 --- a/rostests/apitests/CMakeLists.txt +++ b/rostests/apitests/CMakeLists.txt @@ -6,6 +6,7 @@ add_subdirectory(appshim) add_subdirectory(atl) add_subdirectory(browseui) add_subdirectory(com) +add_subdirectory(comctl32) add_subdirectory(crt) add_subdirectory(dbghelp) add_subdirectory(dciman32) diff --git a/rostests/apitests/comctl32/CMakeLists.txt b/rostests/apitests/comctl32/CMakeLists.txt new file mode 100644 index 00000000000..addee1b5f18 --- /dev/null +++ b/rostests/apitests/comctl32/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_executable(comctl32_apitest button.c testlist.c comctl32_apitest.rc) +target_link_libraries(comctl32_apitest wine) +set_module_type(comctl32_apitest win32cui) +add_importlibs(comctl32_apitest user32 msvcrt kernel32 ntdll) +add_rostests_file(TARGET comctl32_apitest) diff --git a/rostests/apitests/comctl32/button.c b/rostests/apitests/comctl32/button.c new file mode 100644 index 00000000000..2352c3cdd5e --- /dev/null +++ b/rostests/apitests/comctl32/button.c @@ -0,0 +1,90 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for Button window class v6 + * PROGRAMMERS: Giannis Adamopoulos + */ + +#include "wine/test.h" +#include +#include + +#define ok_rect(rc, l,r,t,b) ok((rc.left == (l)) && (rc.right == (r)) && (rc.top == (t)) && (rc.bottom == (b)), "Wrong rect. expected %d, %d, %d, %d got %ld, %ld, %ld, %ld\n", l,t,r,b, rc.left, rc.top, rc.right, rc.bottom) + +void Test_TextMargin() +{ + RECT rc; + BOOL ret; + HWND hwnd1; + + hwnd1 = CreateWindowW(L"Button", L"Test1", 0, 10, 10, 100, 100, 0, NULL, NULL, NULL); + ok (hwnd1 != NULL, "Expected CreateWindowW to succeed\n"); + + ret = SendMessageW(hwnd1, BCM_GETTEXTMARGIN, 0, (LPARAM)&rc); + ok (ret == TRUE, "Expected BCM_GETTEXTMARGIN to succeed\n"); + ok_rect(rc, 1, 1, 1, 1); + + SetRect(&rc, 0,0,0,0); + ret = SendMessageW(hwnd1, BCM_SETTEXTMARGIN, 0, (LPARAM)&rc); + ok (ret == TRUE, "Expected BCM_SETTEXTMARGIN to succeed\n"); + + ret = SendMessageW(hwnd1, BCM_GETTEXTMARGIN, 0, (LPARAM)&rc); + ok (ret == TRUE, "Expected BCM_GETTEXTMARGIN to succeed\n"); + ok_rect(rc, 0, 0, 0, 0); + + SetRect(&rc, -1,-1,-1,-1); + ret = SendMessageW(hwnd1, BCM_SETTEXTMARGIN, 0, (LPARAM)&rc); + ok (ret == TRUE, "Expected BCM_SETTEXTMARGIN to succeed\n"); + + ret = SendMessageW(hwnd1, BCM_GETTEXTMARGIN, 0, (LPARAM)&rc); + ok (ret == TRUE, "Expected BCM_GETTEXTMARGIN to succeed\n"); + ok_rect(rc, -1, -1, -1, -1); + + SetRect(&rc, 1000,1000,1000,1000); + ret = SendMessageW(hwnd1, BCM_SETTEXTMARGIN, 0, (LPARAM)&rc); + ok (ret == TRUE, "Expected BCM_SETTEXTMARGIN to succeed\n"); + + ret = SendMessageW(hwnd1, BCM_GETTEXTMARGIN, 0, (LPARAM)&rc); + ok (ret == TRUE, "Expected BCM_GETTEXTMARGIN to succeed\n"); + ok_rect(rc, 1000, 1000, 1000, 1000); + + DestroyWindow(hwnd1); +} + +void Test_Imagelist() +{ + HWND hwnd1; + BOOL ret; + BUTTON_IMAGELIST imlData; + + hwnd1 = CreateWindowW(L"Button", L"Test2", 0, 10, 10, 100, 100, 0, NULL, NULL, NULL); + ok (hwnd1 != NULL, "Expected CreateWindowW to succeed\n"); + + ret = SendMessageW(hwnd1, BCM_GETIMAGELIST, 0, (LPARAM)&imlData); + ok (ret == TRUE, "Expected BCM_GETIMAGELIST to succeed\n"); + ok (imlData.himl == 0, "Expected 0 himl\n"); + ok (imlData.uAlign == 0, "Expected 0 uAlign\n"); + ok_rect(imlData.margin, 0, 0, 0, 0); + + SetRect(&imlData.margin, 0,0,0,1); + ret = SendMessageW(hwnd1, BCM_SETIMAGELIST, 0, (LPARAM)&imlData); + ok (ret == FALSE, "Expected BCM_SETIMAGELIST to fail\n"); /* This works in win10 */ + + imlData.himl = (HIMAGELIST)0xdead; + ret = SendMessageW(hwnd1, BCM_SETIMAGELIST, 0, (LPARAM)&imlData); + ok (ret == TRUE, "Expected BCM_SETIMAGELIST to fail\n"); /* This works in win10 */ + + ret = SendMessageW(hwnd1, BCM_GETIMAGELIST, 0, (LPARAM)&imlData); + ok (ret == TRUE, "Expected BCM_GETIMAGELIST to succeed\n"); + ok (imlData.himl == (HIMAGELIST)0xdead, "Expected 0 himl\n"); + ok (imlData.uAlign == 0, "Expected 0 uAlign\n"); + ok_rect(imlData.margin, 0, 0, 0, 1); +} + +START_TEST(button) +{ + LoadLibraryW(L"comctl32.dll"); /* same as statically linking to comctl32 and doing InitCommonControls */ + Test_TextMargin(); + Test_Imagelist(); +} + diff --git a/rostests/apitests/comctl32/comctl32_apitest.rc b/rostests/apitests/comctl32/comctl32_apitest.rc new file mode 100644 index 00000000000..375af3a24f2 --- /dev/null +++ b/rostests/apitests/comctl32/comctl32_apitest.rc @@ -0,0 +1,7 @@ +#include +#include +#include + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#include diff --git a/rostests/apitests/comctl32/testlist.c b/rostests/apitests/comctl32/testlist.c new file mode 100644 index 00000000000..ba97026e57b --- /dev/null +++ b/rostests/apitests/comctl32/testlist.c @@ -0,0 +1,10 @@ +#define STANDALONE +#include + +extern void func_button(void); + +const struct test winetest_testlist[] = +{ + { "button", func_button }, + { 0, 0 } +};