[COMCTL32] -Test BCM_SETTEXTMARGIN, BCM_SETIMAGELIST, BCM_GETIMAGELIST and BCM_GETTEX...
[reactos.git] / rostests / apitests / comctl32 / button.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for Button window class v6
5 * PROGRAMMERS: Giannis Adamopoulos
6 */
7
8 #include "wine/test.h"
9 #include <windows.h>
10 #include <commctrl.h>
11
12 #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)
13
14 void Test_TextMargin()
15 {
16 RECT rc;
17 BOOL ret;
18 HWND hwnd1;
19
20 hwnd1 = CreateWindowW(L"Button", L"Test1", 0, 10, 10, 100, 100, 0, NULL, NULL, NULL);
21 ok (hwnd1 != NULL, "Expected CreateWindowW to succeed\n");
22
23 ret = SendMessageW(hwnd1, BCM_GETTEXTMARGIN, 0, (LPARAM)&rc);
24 ok (ret == TRUE, "Expected BCM_GETTEXTMARGIN to succeed\n");
25 ok_rect(rc, 1, 1, 1, 1);
26
27 SetRect(&rc, 0,0,0,0);
28 ret = SendMessageW(hwnd1, BCM_SETTEXTMARGIN, 0, (LPARAM)&rc);
29 ok (ret == TRUE, "Expected BCM_SETTEXTMARGIN to succeed\n");
30
31 ret = SendMessageW(hwnd1, BCM_GETTEXTMARGIN, 0, (LPARAM)&rc);
32 ok (ret == TRUE, "Expected BCM_GETTEXTMARGIN to succeed\n");
33 ok_rect(rc, 0, 0, 0, 0);
34
35 SetRect(&rc, -1,-1,-1,-1);
36 ret = SendMessageW(hwnd1, BCM_SETTEXTMARGIN, 0, (LPARAM)&rc);
37 ok (ret == TRUE, "Expected BCM_SETTEXTMARGIN to succeed\n");
38
39 ret = SendMessageW(hwnd1, BCM_GETTEXTMARGIN, 0, (LPARAM)&rc);
40 ok (ret == TRUE, "Expected BCM_GETTEXTMARGIN to succeed\n");
41 ok_rect(rc, -1, -1, -1, -1);
42
43 SetRect(&rc, 1000,1000,1000,1000);
44 ret = SendMessageW(hwnd1, BCM_SETTEXTMARGIN, 0, (LPARAM)&rc);
45 ok (ret == TRUE, "Expected BCM_SETTEXTMARGIN to succeed\n");
46
47 ret = SendMessageW(hwnd1, BCM_GETTEXTMARGIN, 0, (LPARAM)&rc);
48 ok (ret == TRUE, "Expected BCM_GETTEXTMARGIN to succeed\n");
49 ok_rect(rc, 1000, 1000, 1000, 1000);
50
51 DestroyWindow(hwnd1);
52 }
53
54 void Test_Imagelist()
55 {
56 HWND hwnd1;
57 BOOL ret;
58 BUTTON_IMAGELIST imlData;
59
60 hwnd1 = CreateWindowW(L"Button", L"Test2", 0, 10, 10, 100, 100, 0, NULL, NULL, NULL);
61 ok (hwnd1 != NULL, "Expected CreateWindowW to succeed\n");
62
63 ret = SendMessageW(hwnd1, BCM_GETIMAGELIST, 0, (LPARAM)&imlData);
64 ok (ret == TRUE, "Expected BCM_GETIMAGELIST to succeed\n");
65 ok (imlData.himl == 0, "Expected 0 himl\n");
66 ok (imlData.uAlign == 0, "Expected 0 uAlign\n");
67 ok_rect(imlData.margin, 0, 0, 0, 0);
68
69 SetRect(&imlData.margin, 0,0,0,1);
70 ret = SendMessageW(hwnd1, BCM_SETIMAGELIST, 0, (LPARAM)&imlData);
71 ok (ret == FALSE, "Expected BCM_SETIMAGELIST to fail\n"); /* This works in win10 */
72
73 imlData.himl = (HIMAGELIST)0xdead;
74 ret = SendMessageW(hwnd1, BCM_SETIMAGELIST, 0, (LPARAM)&imlData);
75 ok (ret == TRUE, "Expected BCM_SETIMAGELIST to fail\n"); /* This works in win10 */
76
77 ret = SendMessageW(hwnd1, BCM_GETIMAGELIST, 0, (LPARAM)&imlData);
78 ok (ret == TRUE, "Expected BCM_GETIMAGELIST to succeed\n");
79 ok (imlData.himl == (HIMAGELIST)0xdead, "Expected 0 himl\n");
80 ok (imlData.uAlign == 0, "Expected 0 uAlign\n");
81 ok_rect(imlData.margin, 0, 0, 0, 1);
82 }
83
84 START_TEST(button)
85 {
86 LoadLibraryW(L"comctl32.dll"); /* same as statically linking to comctl32 and doing InitCommonControls */
87 Test_TextMargin();
88 Test_Imagelist();
89 }
90