[PATCH 3/4] comctl32/tests: Fix toolbar size tests that depend on system font height.
Austin Lund
austin.lund at gmail.com
Fri Nov 5 00:31:54 CDT 2010
---
dlls/comctl32/tests/toolbar.c | 51 ++++++++++++++++++++++++++--------------
1 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index 2697994..6da3f6c 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -677,6 +677,17 @@ static void dump_sizes(HWND hToolbar)
#else
+static int system_font_height(void) {
+ HDC hDC;
+ TEXTMETRIC tm;
+
+ hDC = CreateCompatibleDC(NULL);
+ GetTextMetrics(hDC, &tm);
+ DeleteDC(NULL);
+
+ return tm.tmHeight;
+}
+
typedef struct
{
RECT rcClient;
@@ -688,6 +699,8 @@ typedef struct
tbsize_result_t *tbsize_results = NULL;
static void init_tbsize_results(void) {
+ int fontheight = system_font_height();
+
tbsize_results = (tbsize_result_t *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 24*sizeof(tbsize_result_t));
tbsize_results[0] = (tbsize_result_t) { {0, 0, 672, 26}, {100, 22}, 5, {
{ 0, 2, 23, 24}, { 23, 2, 46, 24}, { 46, 2, 54, 24},
@@ -760,23 +773,23 @@ static void init_tbsize_results(void) {
{123, 0, 146, 100}, {146, 0, 169, 100}, {169, 0, 192, 100},
{192, 0, 215, 100} } };
tbsize_results[15] = (tbsize_result_t) { {0, 0, 672, 26}, {238, 39}, 11, {
- { 0, 0, 23, 39}, { 23, 0, 46, 39}, { 46, 0, 54, 39},
- { 54, 0, 77, 39}, { 77, 0, 100, 39}, {100, 0, 123, 39},
- {123, 0, 146, 39}, {146, 0, 169, 39}, {169, 0, 192, 39},
- {192, 0, 215, 39}, {215, 0, 238, 39} } };
+ { 0, 0, 23, 23 + fontheight}, { 23, 0, 46, 23 + fontheight}, { 46, 0, 54, 23 + fontheight},
+ { 54, 0, 77, 23 + fontheight}, { 77, 0, 100, 23 + fontheight}, {100, 0, 123, 23 + fontheight},
+ {123, 0, 146, 23 + fontheight}, {146, 0, 169, 23 + fontheight}, {169, 0, 192, 23 + fontheight},
+ {192, 0, 215, 23 + fontheight}, {215, 0, 238, 23 + fontheight} } };
tbsize_results[16] = (tbsize_result_t) { {0, 0, 672, 26}, {238, 22}, 11, {
{ 0, 0, 23, 22}, { 23, 0, 46, 22}, { 46, 0, 54, 22},
{ 54, 0, 77, 22}, { 77, 0, 100, 22}, {100, 0, 123, 22},
{123, 0, 146, 22}, {146, 0, 169, 22}, {169, 0, 192, 22},
{192, 0, 215, 22}, {215, 0, 238, 22} } };
tbsize_results[17] = (tbsize_result_t) { {0, 0, 672, 26}, {489, 39}, 3, {
- { 0, 2, 163, 41}, {163, 2, 330, 41}, {330, 2, 493, 41} } };
+ { 0, 2, 163, 25 + fontheight}, {163, 2, 330, 25 + fontheight}, {330, 2, 493, 25 + fontheight} } };
tbsize_results[18] = (tbsize_result_t) { {0, 0, 672, 104}, {978, 24}, 6, {
- { 0, 2, 163, 26}, {163, 2, 326, 26}, {326, 2, 489, 26},
- {489, 2, 652, 26}, {652, 2, 819, 26}, {819, 2, 850, 26} } };
+ { 0, 2, 163, 10 + fontheight}, {163, 2, 326, 10 + fontheight}, {326, 2, 489, 10 + fontheight},
+ {489, 2, 652, 10 + fontheight}, {652, 2, 819, 10 + fontheight}, {819, 2, 850, 10 + fontheight} } };
tbsize_results[19] = (tbsize_result_t) { {0, 0, 672, 28}, {978, 38}, 6, {
- { 0, 0, 163, 38}, {163, 0, 326, 38}, {326, 0, 489, 38},
- {489, 0, 652, 38}, {652, 0, 819, 38}, {819, 0, 850, 38} } };
+ { 0, 0, 163, 22 + fontheight}, {163, 0, 326, 22 + fontheight}, {326, 0, 489, 22 + fontheight},
+ {489, 0, 652, 22 + fontheight}, {652, 0, 819, 22 + fontheight}, {819, 0, 850, 22 + fontheight} } };
tbsize_results[20] = (tbsize_result_t) { {0, 0, 672, 100}, {239, 102}, 3, {
{ 0, 2, 100, 102}, {100, 2, 139, 102}, {139, 2, 239, 102} } };
tbsize_results[21] = (tbsize_result_t) { {0, 0, 672, 42}, {185, 40}, 3, {
@@ -784,7 +797,7 @@ static void init_tbsize_results(void) {
tbsize_results[22] = (tbsize_result_t) { {0, 0, 672, 42}, {67, 40}, 1, {
{ 0, 2, 67, 40} } };
tbsize_results[23] = (tbsize_result_t) { {0, 0, 672, 42}, {67, 41}, 2, {
- { 0, 2, 672, 41}, { 0, 41, 672, 80} } };
+ { 0, 2, 672, 25 + fontheight}, { 0, 25 + fontheight, 672, 48 + 2*fontheight} } };
}
static void free_tbsize_results(void) {
@@ -860,6 +873,7 @@ static void test_sizes(void)
TBBUTTONINFO tbinfo;
int style;
int i;
+ int fontheight = system_font_height();
init_tbsize_results();
@@ -936,7 +950,8 @@ static void test_sizes(void)
SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[0]);
/* TB_ADDSTRING resets the size */
SendMessageA(hToolbar, TB_ADDSTRING, 0, (LPARAM)"A\0MMMMMMMMMMMMM\0");
- check_button_size(hToolbar, 23, 39);
+ check_button_size(hToolbar, 23, 23 + fontheight);
+
check_sizes();
/* TB_SETBUTTONSIZE can be used to crop the text */
SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(3, 3));
@@ -971,7 +986,7 @@ static void test_sizes(void)
rebuild_toolbar(&hToolbar);
SendMessageA(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)"A\0MMMMMMMMMMMMM\0");
/* the height is increased after a TB_ADDSTRING */
- check_button_size(hToolbar, 23, 39);
+ check_button_size(hToolbar, 23, 23 + fontheight);
SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(100, 100));
/* if a string is in the pool, even adding a button without a string resets the size */
SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons2[0]);
@@ -979,13 +994,13 @@ static void test_sizes(void)
SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(100, 100));
/* an BTNS_AUTOSIZE button is also considered when computing the new size */
SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[2]);
- check_button_size(hToolbar, 163, 39);
+ check_button_size(hToolbar, 163, 23 + fontheight);
SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[0]);
check_sizes();
/* delete button doesn't change the buttons size */
SendMessageA(hToolbar, TB_DELETEBUTTON, 2, 0);
SendMessageA(hToolbar, TB_DELETEBUTTON, 1, 0);
- check_button_size(hToolbar, 163, 39);
+ check_button_size(hToolbar, 163, 23 + fontheight);
/* TB_INSERTBUTTONS will */
SendMessageA(hToolbar, TB_INSERTBUTTON, 1, (LPARAM)&buttons2[0]);
check_button_size(hToolbar, 23, 22);
@@ -1024,9 +1039,9 @@ static void test_sizes(void)
/* the text is taken into account */
SendMessageA(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)"A\0MMMMMMMMMMMMM\0");
SendMessageA(hToolbar, TB_ADDBUTTONS, 4, (LPARAM)buttons3);
- check_button_size(hToolbar, 163, 38);
+ check_button_size(hToolbar, 163, 22 + fontheight);
ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, 0) == (LRESULT)himl, "TB_SETIMAGELIST failed\n");
- check_button_size(hToolbar, 163, 24);
+ check_button_size(hToolbar, 163, 8 + fontheight);
/* the style change also comes into effect */
check_sizes();
SetWindowLong(hToolbar, GWL_STYLE, GetWindowLong(hToolbar, GWL_STYLE) | TBSTYLE_FLAT);
@@ -1038,9 +1053,9 @@ static void test_sizes(void)
ImageList_Destroy(himl2);
SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[3]);
- check_button_size(hToolbar, 27, 39);
+ check_button_size(hToolbar, 27, 23 + fontheight);
SendMessageA(hToolbar, TB_DELETEBUTTON, 0, 0);
- check_button_size(hToolbar, 27, 39);
+ check_button_size(hToolbar, 27, 23 + fontheight);
rebuild_toolbar(&hToolbar);
--
1.7.1
More information about the wine-patches
mailing list