From e5b4c0f84bf54fa52754e249c36ba04d939d8742 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Tue, 5 Feb 2008 11:59:47 +0100 Subject: [PATCH] comctl32/tests: Call InitCommonControlsEx() if available, fall back to InitCommonControls() for the older controls, and skip the tests altogether for the newer ones. --- dlls/comctl32/tests/comboex.c | 22 ++++++++++++++++++---- dlls/comctl32/tests/datetime.c | 16 +++++++++++++++- dlls/comctl32/tests/header.c | 22 +++++++++++++++++++--- dlls/comctl32/tests/listview.c | 15 ++++++++++++++- dlls/comctl32/tests/monthcal.c | 18 +++++++++++++++--- dlls/comctl32/tests/progress.c | 14 +++++++++++++- dlls/comctl32/tests/rebar.c | 14 +++++++++++++- dlls/comctl32/tests/treeview.c | 15 ++++++++++++++- 8 files changed, 121 insertions(+), 15 deletions(-) diff --git a/dlls/comctl32/tests/comboex.c b/dlls/comctl32/tests/comboex.c index f3f46b3da36..ad58643f648 100644 --- a/dlls/comctl32/tests/comboex.c +++ b/dlls/comctl32/tests/comboex.c @@ -187,10 +187,23 @@ static LRESULT CALLBACK ComboExTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, L return 0L; } -static void init(void) { +static int init(void) +{ + HMODULE hComctl32; + BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); WNDCLASSA wc; + INITCOMMONCONTROLSEX iccex; - InitCommonControls(); + hComctl32 = GetModuleHandleA("comctl32.dll"); + pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); + if (!pInitCommonControlsEx) + { + skip("InitCommonControlsEx() is missing. Skipping the tests\n"); + return 0; + } + iccex.dwSize = sizeof(iccex); + iccex.dwICC = ICC_USEREX_CLASSES; + pInitCommonControlsEx(&iccex); wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbClsExtra = 0; @@ -209,7 +222,7 @@ static void init(void) { assert(hComboExParentWnd != NULL); hMainHinst = GetModuleHandleA(NULL); - + return 1; } static void cleanup(void) @@ -227,7 +240,8 @@ static void cleanup(void) START_TEST(comboex) { - init(); + if (!init()) + return; test_comboboxex(); diff --git a/dlls/comctl32/tests/datetime.c b/dlls/comctl32/tests/datetime.c index d13abc6454b..73c7af3f901 100644 --- a/dlls/comctl32/tests/datetime.c +++ b/dlls/comctl32/tests/datetime.c @@ -560,7 +560,21 @@ static void test_datetime_control(void) START_TEST(datetime) { - InitCommonControls(); + HMODULE hComctl32; + BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); + INITCOMMONCONTROLSEX iccex; + + hComctl32 = GetModuleHandleA("comctl32.dll"); + pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); + if (!pInitCommonControlsEx) + { + skip("InitCommonControlsEx() is missing. Skipping the tests\n"); + return; + } + iccex.dwSize = sizeof(iccex); + iccex.dwICC = ICC_DATE_CLASSES; + pInitCommonControlsEx(&iccex); + init_msg_sequences(sequences, NUM_MSG_SEQUENCES); test_datetime_control(); diff --git a/dlls/comctl32/tests/header.c b/dlls/comctl32/tests/header.c index 884d4d527ce..6f8b46250f8 100644 --- a/dlls/comctl32/tests/header.c +++ b/dlls/comctl32/tests/header.c @@ -1480,10 +1480,24 @@ static LRESULT CALLBACK HeaderTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LP return 0L; } -static void init(void) { +static int init(void) +{ + HMODULE hComctl32; + BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); WNDCLASSA wc; + INITCOMMONCONTROLSEX iccex; - InitCommonControls(); + hComctl32 = GetModuleHandleA("comctl32.dll"); + pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); + if (!pInitCommonControlsEx) + { + skip("InitCommonControlsEx() is missing. Skipping the tests\n"); + return 0; + } + + iccex.dwSize = sizeof(iccex); + iccex.dwICC = ICC_USEREX_CLASSES; + pInitCommonControlsEx(&iccex); wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbClsExtra = 0; @@ -1503,13 +1517,15 @@ static void init(void) { NULL, NULL, GetModuleHandleA(NULL), 0); assert(hHeaderParentWnd != NULL); ShowWindow(hHeaderParentWnd, SW_SHOW); + return 1; } START_TEST(header) { HWND parent_hwnd; - init(); + if (!init()) + return; test_header_control(); test_header_order(); diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 30a81a8948f..6e6f535fba1 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -1040,7 +1040,20 @@ static void test_item_position(void) START_TEST(listview) { - InitCommonControls(); + HMODULE hComctl32; + BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); + + hComctl32 = GetModuleHandleA("comctl32.dll"); + pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); + if (pInitCommonControlsEx) + { + INITCOMMONCONTROLSEX iccex; + iccex.dwSize = sizeof(iccex); + iccex.dwICC = ICC_LISTVIEW_CLASSES; + pInitCommonControlsEx(&iccex); + } + else + InitCommonControls(); init_msg_sequences(sequences, NUM_MSG_SEQUENCES); diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c index 7fe2bd761c7..d33f07c9805 100644 --- a/dlls/comctl32/tests/monthcal.c +++ b/dlls/comctl32/tests/monthcal.c @@ -315,7 +315,6 @@ static void test_monthcal(void) SYSTEMTIME st[2], st1[2]; int res, month_range; - InitCommonControls(); hwnd = CreateWindowA(MONTHCAL_CLASSA, "MonthCal", WS_POPUP | WS_VISIBLE, CW_USEDEFAULT, 0, 300, 300, 0, 0, NULL, NULL); ok(hwnd != NULL, "Failed to create MonthCal\n"); @@ -478,8 +477,6 @@ static HWND create_monthcal_control(DWORD style, HWND parent_window) struct subclass_info *info; HWND hwnd; - InitCommonControls(); - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); if (!info) return NULL; @@ -1109,7 +1106,22 @@ static void test_monthcal_MaxSelDay(HWND hwnd) START_TEST(monthcal) { + HMODULE hComctl32; + BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); + INITCOMMONCONTROLSEX iccex; HWND hwnd, parent_wnd; + + hComctl32 = GetModuleHandleA("comctl32.dll"); + pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); + if (!pInitCommonControlsEx) + { + skip("InitCommonControlsEx() is missing. Skipping the tests\n"); + return; + } + iccex.dwSize = sizeof(iccex); + iccex.dwICC = ICC_DATE_CLASSES; + pInitCommonControlsEx(&iccex); + test_monthcal(); init_msg_sequences(sequences, NUM_MSG_SEQUENCES); diff --git a/dlls/comctl32/tests/progress.c b/dlls/comctl32/tests/progress.c index 2716f3356b4..10bbbef8a28 100644 --- a/dlls/comctl32/tests/progress.c +++ b/dlls/comctl32/tests/progress.c @@ -90,10 +90,22 @@ static void update_window(HWND hWnd) static void init(void) { + HMODULE hComctl32; + BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); WNDCLASSA wc; RECT rect; - InitCommonControls(); + hComctl32 = GetModuleHandleA("comctl32.dll"); + pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); + if (pInitCommonControlsEx) + { + INITCOMMONCONTROLSEX iccex; + iccex.dwSize = sizeof(iccex); + iccex.dwICC = ICC_PROGRESS_CLASS; + pInitCommonControlsEx(&iccex); + } + else + InitCommonControls(); wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbClsExtra = 0; diff --git a/dlls/comctl32/tests/rebar.c b/dlls/comctl32/tests/rebar.c index 6bebeb770a4..1de9cd2a7a7 100644 --- a/dlls/comctl32/tests/rebar.c +++ b/dlls/comctl32/tests/rebar.c @@ -786,11 +786,23 @@ static void bandinfo_test(void) START_TEST(rebar) { + HMODULE hComctl32; + BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); + INITCOMMONCONTROLSEX iccex; WNDCLASSA wc; MSG msg; RECT rc; - InitCommonControls(); + hComctl32 = GetModuleHandleA("comctl32.dll"); + pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); + if (!pInitCommonControlsEx) + { + skip("InitCommonControlsEx() is missing. Skipping the tests\n"); + return; + } + iccex.dwSize = sizeof(iccex); + iccex.dwICC = ICC_COOL_CLASSES; + pInitCommonControlsEx(&iccex); wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbClsExtra = 0; diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c index 93010d3065e..c1ba7f309be 100644 --- a/dlls/comctl32/tests/treeview.c +++ b/dlls/comctl32/tests/treeview.c @@ -649,10 +649,23 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa START_TEST(treeview) { + HMODULE hComctl32; + BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); WNDCLASSA wc; MSG msg; - InitCommonControls(); + hComctl32 = GetModuleHandleA("comctl32.dll"); + pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); + if (pInitCommonControlsEx) + { + INITCOMMONCONTROLSEX iccex; + iccex.dwSize = sizeof(iccex); + iccex.dwICC = ICC_TREEVIEW_CLASSES; + pInitCommonControlsEx(&iccex); + } + else + InitCommonControls(); + init_msg_sequences(MsgSequences, NUM_MSG_SEQUENCES); wc.style = CS_HREDRAW | CS_VREDRAW;