Commit cb7a426c authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/tests: Use actual text width for ideal button size tests.

parent 76bc23d8
...@@ -1421,21 +1421,21 @@ static void test_state(void) ...@@ -1421,21 +1421,21 @@ static void test_state(void)
static void test_bcm_get_ideal_size(void) static void test_bcm_get_ideal_size(void)
{ {
static const WCHAR text2_w[] = {'t', 'e', 'x', 't', '\n', 't', 'e', 'x', 't', 0}; static const char *button_text2 = "WWWW\nWWWW";
static const WCHAR text_w[] = {'t', 'e', 'x', 't', 0}; static const char *button_text = "WWWW";
static const DWORD imagelist_aligns[] = {BUTTON_IMAGELIST_ALIGN_LEFT, BUTTON_IMAGELIST_ALIGN_RIGHT, static const DWORD imagelist_aligns[] = {BUTTON_IMAGELIST_ALIGN_LEFT, BUTTON_IMAGELIST_ALIGN_RIGHT,
BUTTON_IMAGELIST_ALIGN_TOP, BUTTON_IMAGELIST_ALIGN_BOTTOM, BUTTON_IMAGELIST_ALIGN_TOP, BUTTON_IMAGELIST_ALIGN_BOTTOM,
BUTTON_IMAGELIST_ALIGN_CENTER}; BUTTON_IMAGELIST_ALIGN_CENTER};
static const DWORD aligns[] = {0, BS_TOP, BS_LEFT, BS_RIGHT, BS_BOTTOM, static const DWORD aligns[] = {0, BS_TOP, BS_LEFT, BS_RIGHT, BS_BOTTOM,
BS_CENTER, BS_VCENTER, BS_RIGHTBUTTON, WS_EX_RIGHT}; BS_CENTER, BS_VCENTER, BS_RIGHTBUTTON, WS_EX_RIGHT};
DWORD default_style = WS_TABSTOP | WS_POPUP | WS_VISIBLE; DWORD default_style = WS_TABSTOP | WS_POPUP | WS_VISIBLE;
LONG client_width = 200, client_height = 200; const LONG client_width = 400, client_height = 200;
LONG width, height, line_count; LONG image_width, height, line_count, text_width;
HFONT hfont, prev_font;
DWORD style, type; DWORD style, type;
BOOL ret; BOOL ret;
HWND hwnd; HWND hwnd;
HDC hdc; HDC hdc;
HFONT hfont;
LOGFONTA lf; LOGFONTA lf;
TEXTMETRICA tm; TEXTMETRICA tm;
SIZE size; SIZE size;
...@@ -1444,11 +1444,12 @@ static void test_bcm_get_ideal_size(void) ...@@ -1444,11 +1444,12 @@ static void test_bcm_get_ideal_size(void)
HICON hicon; HICON hicon;
HIMAGELIST himl; HIMAGELIST himl;
BUTTON_IMAGELIST biml = {0}; BUTTON_IMAGELIST biml = {0};
RECT rect;
INT i, j; INT i, j;
/* Check for NULL pointer handling */ /* Check for NULL pointer handling */
hwnd = CreateWindowW(WC_BUTTONW, text_w, BS_PUSHBUTTON | default_style, 0, 0, client_width, client_height, NULL, hwnd = CreateWindowA(WC_BUTTONA, button_text, BS_PUSHBUTTON | default_style, 0, 0, client_width, client_height,
NULL, 0, NULL); NULL, NULL, 0, NULL);
ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, 0); ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, 0);
ok(!ret, "Expect BCM_GETIDEALSIZE message to return false.\n"); ok(!ret, "Expect BCM_GETIDEALSIZE message to return false.\n");
...@@ -1458,22 +1459,27 @@ static void test_bcm_get_ideal_size(void) ...@@ -1458,22 +1459,27 @@ static void test_bcm_get_ideal_size(void)
lf.lfHeight = 20; lf.lfHeight = 20;
lstrcpyA(lf.lfFaceName, "Tahoma"); lstrcpyA(lf.lfFaceName, "Tahoma");
hfont = CreateFontIndirectA(&lf); hfont = CreateFontIndirectA(&lf);
ok(hfont != NULL, "Failed to create test font.\n");
/* Get tmHeight */ /* Get tmHeight */
hdc = GetDC(hwnd); hdc = GetDC(hwnd);
prev_font = SelectObject(hdc, hfont);
GetTextMetricsA(hdc, &tm); GetTextMetricsA(hdc, &tm);
SelectObject(hdc, prev_font);
DrawTextA(hdc, button_text, -1, &rect, DT_CALCRECT);
text_width = rect.right - rect.left;
ReleaseDC(hwnd, hdc); ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd); DestroyWindow(hwnd);
/* XP and 2003 doesn't support command links, getting ideal size with button having only text just return client size on these platforms */ /* XP and 2003 doesn't support command links, getting ideal size with button having only text returns client size on these platforms. */
hwnd = CreateWindowA(WC_BUTTONA, "test", BS_DEFCOMMANDLINK | default_style, 0, 0, client_width, client_height, NULL, hwnd = CreateWindowA(WC_BUTTONA, button_text, BS_DEFCOMMANDLINK | default_style, 0, 0, client_width, client_height, NULL,
NULL, 0, NULL); NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
ZeroMemory(&size, sizeof(size)); ZeroMemory(&size, sizeof(size));
ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size); ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size);
ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n"); ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n");
if (size.cx == client_width && size.cy == client_width) if (size.cx == client_width && size.cy == client_height)
{ {
/* on XP and 2003, buttons with image are not supported */ /* on XP and 2003, buttons with image are not supported */
win_skip("Skipping further tests on XP and 2003\n"); win_skip("Skipping further tests on XP and 2003\n");
...@@ -1482,14 +1488,14 @@ static void test_bcm_get_ideal_size(void) ...@@ -1482,14 +1488,14 @@ static void test_bcm_get_ideal_size(void)
/* Tests for image placements */ /* Tests for image placements */
/* Prepare bitmap */ /* Prepare bitmap */
width = 48; image_width = 48;
height = 48; height = 48;
hdc = GetDC(0); hdc = GetDC(0);
hmask = CreateCompatibleBitmap(hdc, width, height); hmask = CreateCompatibleBitmap(hdc, image_width, height);
hbmp = CreateCompatibleBitmap(hdc, width, height); hbmp = CreateCompatibleBitmap(hdc, image_width, height);
/* Only bitmap for push button, ideal size should be enough for image and text */ /* Only bitmap for push button, ideal size should be enough for image and text */
hwnd = CreateWindowA(WC_BUTTONA, "WWWW", BS_DEFPUSHBUTTON | BS_BITMAP | default_style, 0, 0, client_width, hwnd = CreateWindowA(WC_BUTTONA, button_text, BS_DEFPUSHBUTTON | BS_BITMAP | default_style, 0, 0, client_width,
client_height, NULL, NULL, 0, NULL); client_height, NULL, NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp); SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp);
...@@ -1498,9 +1504,9 @@ static void test_bcm_get_ideal_size(void) ...@@ -1498,9 +1504,9 @@ static void test_bcm_get_ideal_size(void)
ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size); ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size);
ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n"); ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n");
/* Ideal size contains text rect even show bitmap only */ /* Ideal size contains text rect even show bitmap only */
ok((size.cx >= width + 4 * tm.tmMaxCharWidth && size.cy >= max(height, tm.tmHeight)), ok((size.cx >= image_width + text_width && size.cy >= max(height, tm.tmHeight)),
"Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, width + 4 * tm.tmMaxCharWidth, size.cy, "Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, image_width + text_width,
max(height, tm.tmHeight)); size.cy, max(height, tm.tmHeight));
DestroyWindow(hwnd); DestroyWindow(hwnd);
/* Image alignments when button has bitmap and text*/ /* Image alignments when button has bitmap and text*/
...@@ -1508,7 +1514,7 @@ static void test_bcm_get_ideal_size(void) ...@@ -1508,7 +1514,7 @@ static void test_bcm_get_ideal_size(void)
for (j = 0; j < ARRAY_SIZE(aligns); j++) for (j = 0; j < ARRAY_SIZE(aligns); j++)
{ {
style = BS_DEFPUSHBUTTON | default_style | aligns[i] | aligns[j]; style = BS_DEFPUSHBUTTON | default_style | aligns[i] | aligns[j];
hwnd = CreateWindowA(WC_BUTTONA, "WWWW", style, 0, 0, client_width, client_height, NULL, NULL, 0, NULL); hwnd = CreateWindowA(WC_BUTTONA, button_text, style, 0, 0, client_width, client_height, NULL, NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp); SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
...@@ -1517,25 +1523,25 @@ static void test_bcm_get_ideal_size(void) ...@@ -1517,25 +1523,25 @@ static void test_bcm_get_ideal_size(void)
ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n"); ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n");
if (!(style & (BS_CENTER | BS_VCENTER)) || ((style & BS_CENTER) && (style & BS_CENTER) != BS_CENTER) if (!(style & (BS_CENTER | BS_VCENTER)) || ((style & BS_CENTER) && (style & BS_CENTER) != BS_CENTER)
|| !(style & BS_VCENTER) || (style & BS_VCENTER) == BS_VCENTER) || !(style & BS_VCENTER) || (style & BS_VCENTER) == BS_VCENTER)
ok((size.cx >= width + 4 * tm.tmMaxCharWidth && size.cy >= max(height, tm.tmHeight)), ok((size.cx >= image_width + text_width && size.cy >= max(height, tm.tmHeight)),
"Style: 0x%08x expect ideal cx %d >= %d and ideal cy %d >= %d\n", style, size.cx, "Style: 0x%08x expect ideal cx %d >= %d and ideal cy %d >= %d\n", style, size.cx,
width + 4 * tm.tmMaxCharWidth, size.cy, max(height, tm.tmHeight)); image_width + text_width, size.cy, max(height, tm.tmHeight));
else else
ok((size.cx >= max(4 * tm.tmMaxCharWidth, height) && size.cy >= height + tm.tmHeight), ok((size.cx >= max(text_width, height) && size.cy >= height + tm.tmHeight),
"Style: 0x%08x expect ideal cx %d >= %d and ideal cy %d >= %d\n", style, size.cx, "Style: 0x%08x expect ideal cx %d >= %d and ideal cy %d >= %d\n", style, size.cx,
max(4 * tm.tmMaxCharWidth, height), size.cy, height + tm.tmHeight); max(text_width, height), size.cy, height + tm.tmHeight);
DestroyWindow(hwnd); DestroyWindow(hwnd);
} }
/* Image list alignments */ /* Image list alignments */
himl = pImageList_Create(width, height, ILC_COLOR, 1, 1); himl = pImageList_Create(image_width, height, ILC_COLOR, 1, 1);
pImageList_Add(himl, hbmp, 0); pImageList_Add(himl, hbmp, 0);
biml.himl = himl; biml.himl = himl;
for (i = 0; i < ARRAY_SIZE(imagelist_aligns); i++) for (i = 0; i < ARRAY_SIZE(imagelist_aligns); i++)
{ {
biml.uAlign = imagelist_aligns[i]; biml.uAlign = imagelist_aligns[i];
hwnd = CreateWindowA(WC_BUTTONA, "WWWW", BS_DEFPUSHBUTTON | default_style, 0, 0, client_width, client_height, hwnd = CreateWindowA(WC_BUTTONA, button_text, BS_DEFPUSHBUTTON | default_style, 0, 0, client_width,
NULL, NULL, 0, NULL); client_height, NULL, NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
SendMessageA(hwnd, BCM_SETIMAGELIST, 0, (LPARAM)&biml); SendMessageA(hwnd, BCM_SETIMAGELIST, 0, (LPARAM)&biml);
...@@ -1543,16 +1549,16 @@ static void test_bcm_get_ideal_size(void) ...@@ -1543,16 +1549,16 @@ static void test_bcm_get_ideal_size(void)
ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size); ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size);
ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n"); ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n");
if (biml.uAlign == BUTTON_IMAGELIST_ALIGN_TOP || biml.uAlign == BUTTON_IMAGELIST_ALIGN_BOTTOM) if (biml.uAlign == BUTTON_IMAGELIST_ALIGN_TOP || biml.uAlign == BUTTON_IMAGELIST_ALIGN_BOTTOM)
ok((size.cx >= max(4 * tm.tmMaxCharWidth, height) && size.cy >= height + tm.tmHeight), ok((size.cx >= max(text_width, height) && size.cy >= height + tm.tmHeight),
"Align:%d expect ideal cx %d >= %d and ideal cy %d >= %d\n", biml.uAlign, size.cx, "Align:%d expect ideal cx %d >= %d and ideal cy %d >= %d\n", biml.uAlign, size.cx,
max(4 * tm.tmMaxCharWidth, height), size.cy, height + tm.tmHeight); max(text_width, height), size.cy, height + tm.tmHeight);
else if (biml.uAlign == BUTTON_IMAGELIST_ALIGN_LEFT || biml.uAlign == BUTTON_IMAGELIST_ALIGN_RIGHT) else if (biml.uAlign == BUTTON_IMAGELIST_ALIGN_LEFT || biml.uAlign == BUTTON_IMAGELIST_ALIGN_RIGHT)
ok((size.cx >= width + 4 * tm.tmMaxCharWidth && size.cy >= max(height, tm.tmHeight)), ok((size.cx >= image_width + text_width && size.cy >= max(height, tm.tmHeight)),
"Align:%d expect ideal cx %d >= %d and ideal cy %d >= %d\n", biml.uAlign, size.cx, "Align:%d expect ideal cx %d >= %d and ideal cy %d >= %d\n", biml.uAlign, size.cx,
width + 4 * tm.tmMaxCharWidth, size.cy, max(height, tm.tmHeight)); image_width + text_width, size.cy, max(height, tm.tmHeight));
else else
ok(size.cx >= width && size.cy >= height, "Align:%d expect ideal cx %d >= %d and ideal cy %d >= %d\n", ok(size.cx >= image_width && size.cy >= height, "Align:%d expect ideal cx %d >= %d and ideal cy %d >= %d\n",
biml.uAlign, size.cx, width, size.cy, height); biml.uAlign, size.cx, image_width, size.cy, height);
DestroyWindow(hwnd); DestroyWindow(hwnd);
} }
...@@ -1565,7 +1571,7 @@ static void test_bcm_get_ideal_size(void) ...@@ -1565,7 +1571,7 @@ static void test_bcm_get_ideal_size(void)
hicon = CreateIconIndirect(&icon_info); hicon = CreateIconIndirect(&icon_info);
/* Only icon, ideal size should be enough for image and text */ /* Only icon, ideal size should be enough for image and text */
hwnd = CreateWindowA(WC_BUTTONA, "WWWW", BS_DEFPUSHBUTTON | BS_ICON | default_style, 0, 0, client_width, hwnd = CreateWindowA(WC_BUTTONA, button_text, BS_DEFPUSHBUTTON | BS_ICON | default_style, 0, 0, client_width,
client_height, NULL, NULL, 0, NULL); client_height, NULL, NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon); SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon);
...@@ -1574,44 +1580,44 @@ static void test_bcm_get_ideal_size(void) ...@@ -1574,44 +1580,44 @@ static void test_bcm_get_ideal_size(void)
ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size); ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size);
ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n"); ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n");
/* Ideal size contains text rect even show icons only */ /* Ideal size contains text rect even show icons only */
ok((size.cx >= width + 4 * tm.tmMaxCharWidth && size.cy >= max(height, tm.tmHeight)), ok((size.cx >= image_width + text_width && size.cy >= max(height, tm.tmHeight)),
"Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, width + 4 * tm.tmMaxCharWidth, size.cy, "Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, image_width + text_width, size.cy,
max(height, tm.tmHeight)); max(height, tm.tmHeight));
DestroyWindow(hwnd); DestroyWindow(hwnd);
/* Show icon and text */ /* Show icon and text */
hwnd = CreateWindowA(WC_BUTTONA, "WWWW", BS_DEFPUSHBUTTON | default_style, 0, 0, client_width, client_height, NULL, hwnd = CreateWindowA(WC_BUTTONA, button_text, BS_DEFPUSHBUTTON | default_style, 0, 0, client_width,
NULL, 0, NULL); client_height, NULL, NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon); SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
ZeroMemory(&size, sizeof(size)); ZeroMemory(&size, sizeof(size));
ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size); ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size);
ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n"); ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n");
ok((size.cx >= width + 4 * tm.tmMaxCharWidth && size.cy >= max(height, tm.tmHeight)), ok((size.cx >= image_width + text_width && size.cy >= max(height, tm.tmHeight)),
"Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, width + 4 * tm.tmMaxCharWidth, size.cy, "Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, image_width + text_width, size.cy,
max(height, tm.tmHeight)); max(height, tm.tmHeight));
DestroyWindow(hwnd); DestroyWindow(hwnd);
/* Checkbox */ /* Checkbox */
/* Both bitmap and text for checkbox, ideal size is only enough for text because it doesn't support image(but not image list)*/ /* Both bitmap and text for checkbox, ideal size is only enough for text because it doesn't support image(but not image list)*/
hwnd = CreateWindowA(WC_BUTTONA, "WWWW", BS_AUTOCHECKBOX | default_style, 0, 0, client_width, client_height, NULL, hwnd = CreateWindowA(WC_BUTTONA, button_text, BS_AUTOCHECKBOX | default_style, 0, 0, client_width, client_height,
NULL, 0, NULL); NULL, NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp); SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
ZeroMemory(&size, sizeof(size)); ZeroMemory(&size, sizeof(size));
ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size); ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size);
ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n"); ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n");
ok((size.cx <= width + 4 * tm.tmMaxCharWidth && size.cx >= 4 * tm.tmMaxCharWidth ok((size.cx <= image_width + text_width && size.cx >= text_width && size.cy <= max(height, tm.tmHeight)
&& size.cy <= max(height, tm.tmHeight) && size.cy >= tm.tmHeight), && size.cy >= tm.tmHeight),
"Expect ideal cx %d within range (%d, %d ) and ideal cy %d within range (%d, %d )\n", size.cx, "Expect ideal cx %d within range (%d, %d ) and ideal cy %d within range (%d, %d )\n", size.cx,
4 * tm.tmMaxCharWidth, width + 4 * tm.tmMaxCharWidth, size.cy, tm.tmHeight, max(height, tm.tmHeight)); text_width, image_width + text_width, size.cy, tm.tmHeight, max(height, tm.tmHeight));
DestroyWindow(hwnd); DestroyWindow(hwnd);
/* Both image list and text for checkbox, ideal size should have enough for image list and text */ /* Both image list and text for checkbox, ideal size should have enough for image list and text */
biml.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT; biml.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT;
hwnd = CreateWindowA(WC_BUTTONA, "WWWW", BS_AUTOCHECKBOX | BS_BITMAP | default_style, 0, 0, client_width, hwnd = CreateWindowA(WC_BUTTONA, button_text, BS_AUTOCHECKBOX | BS_BITMAP | default_style, 0, 0, client_width,
client_height, NULL, NULL, 0, NULL); client_height, NULL, NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, BCM_SETIMAGELIST, 0, (LPARAM)&biml); SendMessageA(hwnd, BCM_SETIMAGELIST, 0, (LPARAM)&biml);
...@@ -1619,13 +1625,13 @@ static void test_bcm_get_ideal_size(void) ...@@ -1619,13 +1625,13 @@ static void test_bcm_get_ideal_size(void)
ZeroMemory(&size, sizeof(size)); ZeroMemory(&size, sizeof(size));
ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size); ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size);
ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n"); ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n");
ok((size.cx >= width + 4 * tm.tmMaxCharWidth && size.cy >= max(height, tm.tmHeight)), ok((size.cx >= image_width + text_width && size.cy >= max(height, tm.tmHeight)),
"Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, width + 4 * tm.tmMaxCharWidth, size.cy, "Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, image_width + text_width, size.cy,
max(height, tm.tmHeight)); max(height, tm.tmHeight));
DestroyWindow(hwnd); DestroyWindow(hwnd);
/* Only bitmap for checkbox, ideal size should have enough for image and text */ /* Only bitmap for checkbox, ideal size should have enough for image and text */
hwnd = CreateWindowA(WC_BUTTONA, "WWWW", BS_AUTOCHECKBOX | BS_BITMAP | default_style, 0, 0, client_width, hwnd = CreateWindowA(WC_BUTTONA, button_text, BS_AUTOCHECKBOX | BS_BITMAP | default_style, 0, 0, client_width,
client_height, NULL, NULL, 0, NULL); client_height, NULL, NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp); SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp);
...@@ -1633,8 +1639,8 @@ static void test_bcm_get_ideal_size(void) ...@@ -1633,8 +1639,8 @@ static void test_bcm_get_ideal_size(void)
ZeroMemory(&size, sizeof(size)); ZeroMemory(&size, sizeof(size));
ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size); ret = SendMessageA(hwnd, BCM_GETIDEALSIZE, 0, (LPARAM)&size);
ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n"); ok(ret, "Expect BCM_GETIDEALSIZE message to return true\n");
ok((size.cx >= width + 4 * tm.tmMaxCharWidth && size.cy >= max(height, tm.tmHeight)), ok((size.cx >= image_width + text_width && size.cy >= max(height, tm.tmHeight)),
"Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, width + 4 * tm.tmMaxCharWidth, size.cy, "Expect ideal cx %d >= %d and ideal cy %d >= %d\n", size.cx, image_width + text_width, size.cy,
max(height, tm.tmHeight)); max(height, tm.tmHeight));
DestroyWindow(hwnd); DestroyWindow(hwnd);
...@@ -1673,7 +1679,7 @@ static void test_bcm_get_ideal_size(void) ...@@ -1673,7 +1679,7 @@ static void test_bcm_get_ideal_size(void)
style = line_count > 1 ? type | BS_MULTILINE : type; style = line_count > 1 ? type | BS_MULTILINE : type;
style |= default_style; style |= default_style;
hwnd = CreateWindowW(WC_BUTTONW, (line_count == 2 ? text2_w : text_w), style, 0, 0, client_width, hwnd = CreateWindowA(WC_BUTTONA, (line_count == 2 ? button_text2 : button_text), style, 0, 0, client_width,
client_height, NULL, NULL, 0, NULL); client_height, NULL, NULL, 0, NULL);
ok(hwnd != NULL, "Expect hwnd not NULL\n"); ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
...@@ -1696,11 +1702,9 @@ static void test_bcm_get_ideal_size(void) ...@@ -1696,11 +1702,9 @@ static void test_bcm_get_ideal_size(void)
} }
else else
{ {
width = 0;
height = line_count == 2 ? 2 * tm.tmHeight : tm.tmHeight; height = line_count == 2 ? 2 * tm.tmHeight : tm.tmHeight;
ok(size.cx >= width && size.cy >= height, ok(size.cx >= 0 && size.cy >= height, "Style 0x%08x expect ideal cx %d >= 0 and ideal cy %d >= %d\n",
"Style 0x%08x expect ideal cx %d >= %d and ideal cy %d >= %d\n", style, size.cx, width, size.cy, style, size.cx, size.cy, height);
height);
} }
DestroyWindow(hwnd); DestroyWindow(hwnd);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment