comctl32/tests: Fix band info tests that depend on system font heights.
authorAustin Lund <austin.lund@gmail.com>
Wed, 10 Nov 2010 02:27:10 +0000 (12:27 +1000)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 10 Nov 2010 15:17:05 +0000 (16:17 +0100)
dlls/comctl32/tests/rebar.c

index 98fd4e5c731aac1386748775bb69c48f7fe3c1d9..c62844b0a5da8845ca4a19a1076c112efbc2a647 100644 (file)
@@ -32,6 +32,7 @@
 
 static RECT height_change_notify_rect;
 static HWND hMainWnd;
+static int system_font_height;
 
 
 #define check_rect(name, val, exp) ok(val.top == exp.top && val.bottom == exp.bottom && \
@@ -65,6 +66,17 @@ static BOOL is_font_installed(const char *name)
     return ret;
 }
 
+static void init_system_font_height(void) {
+    HDC hDC;
+    TEXTMETRIC tm;
+
+    hDC = CreateCompatibleDC(NULL);
+    GetTextMetrics(hDC, &tm);
+    DeleteDC(NULL);
+
+    system_font_height = tm.tmHeight;
+}
+
 static HWND create_rebar_control(void)
 {
     HWND hwnd;
@@ -814,13 +826,13 @@ static void test_bandinfo(void)
     rb.fMask = RBBIM_TEXT;
     rb.lpText = szABC;
     ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFO failed\n");
-    expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 35, -1);
+    expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 3 + 2*system_font_height, -1);
 
     rb.cbSize = REBARBANDINFOA_V6_SIZE;
     rb.fMask = 0;
     ok(SendMessageA(hRebar, RB_INSERTBANDA, 1, (LPARAM)&rb), "RB_INSERTBAND failed\n");
     expect_band_content(hRebar, 1, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 0, 0, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 9, -1);
-    expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 40, -1);
+    expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 8 + 2*system_font_height, -1);
 
     rb.fMask = RBBIM_HEADERSIZE;
     rb.cxHeader = 50;
@@ -839,7 +851,7 @@ static void test_bandinfo(void)
     rb.fStyle = RBBS_VARIABLEHEIGHT;
     rb.lpText = szABC;
     ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFO failed\n");
-    expect_band_content(hRebar, 0, RBBS_VARIABLEHEIGHT, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 20, 0x7fffffff, 0, 0, 0, 40, 5);
+    expect_band_content(hRebar, 0, RBBS_VARIABLEHEIGHT, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 20, 0x7fffffff, 0, 0, 0, 8 + 2*system_font_height, 5);
 
     DestroyWindow(hRebar);
 }
@@ -962,6 +974,8 @@ START_TEST(rebar)
     INITCOMMONCONTROLSEX iccex;
     MSG msg;
 
+    init_system_font_height();
+
     /* LoadLibrary is needed. This file has no references to functions in comctl32 */
     hComctl32 = LoadLibraryA("comctl32.dll");
     pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");