mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 12:11:42 +00:00
[COMCTL32_WINETEST] Sync with Wine Staging 3.3. CORE-14434
This commit is contained in:
parent
c3b4d356eb
commit
f37104dadf
32 changed files with 2223 additions and 1032 deletions
|
@ -17,10 +17,21 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
static HWND hProgressParentWnd, hProgressWnd;
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
#include "commctrl.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#include "v6util.h"
|
||||
|
||||
static HWND hProgressParentWnd;
|
||||
static const char progressTestClass[] = "ProgressBarTestClass";
|
||||
static BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
|
||||
|
||||
static HWND create_progress(DWORD style)
|
||||
{
|
||||
|
@ -85,24 +96,10 @@ static void update_window(HWND hWnd)
|
|||
|
||||
static void init(void)
|
||||
{
|
||||
HMODULE hComctl32;
|
||||
BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
|
||||
WNDCLASSA wc;
|
||||
RECT rect;
|
||||
BOOL ret;
|
||||
|
||||
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;
|
||||
wc.cbWndExtra = 0;
|
||||
|
@ -123,16 +120,6 @@ static void init(void)
|
|||
CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, GetModuleHandleA(NULL), 0);
|
||||
ok(hProgressParentWnd != NULL, "failed to create parent wnd\n");
|
||||
|
||||
GetClientRect(hProgressParentWnd, &rect);
|
||||
hProgressWnd = CreateWindowExA(0, PROGRESS_CLASSA, "", WS_CHILD | WS_VISIBLE,
|
||||
0, 0, rect.right, rect.bottom, hProgressParentWnd, NULL, GetModuleHandleA(NULL), 0);
|
||||
ok(hProgressWnd != NULL, "failed to create parent wnd\n");
|
||||
progress_wndproc = (WNDPROC)SetWindowLongPtrA(hProgressWnd, GWLP_WNDPROC, (LPARAM)progress_subclass_proc);
|
||||
|
||||
ShowWindow(hProgressParentWnd, SW_SHOWNORMAL);
|
||||
ok(GetUpdateRect(hProgressParentWnd, NULL, FALSE), "GetUpdateRect: There should be a region that needs to be updated\n");
|
||||
flush_events();
|
||||
update_window(hProgressParentWnd);
|
||||
}
|
||||
|
||||
static void cleanup(void)
|
||||
|
@ -155,9 +142,21 @@ static void cleanup(void)
|
|||
*/
|
||||
static void test_redraw(void)
|
||||
{
|
||||
RECT client_rect;
|
||||
RECT client_rect, rect;
|
||||
HWND hProgressWnd;
|
||||
LRESULT ret;
|
||||
|
||||
GetClientRect(hProgressParentWnd, &rect);
|
||||
hProgressWnd = CreateWindowExA(0, PROGRESS_CLASSA, "", WS_CHILD | WS_VISIBLE,
|
||||
0, 0, rect.right, rect.bottom, hProgressParentWnd, NULL, GetModuleHandleA(NULL), 0);
|
||||
ok(hProgressWnd != NULL, "Failed to create progress bar.\n");
|
||||
progress_wndproc = (WNDPROC)SetWindowLongPtrA(hProgressWnd, GWLP_WNDPROC, (LPARAM)progress_subclass_proc);
|
||||
|
||||
ShowWindow(hProgressParentWnd, SW_SHOWNORMAL);
|
||||
ok(GetUpdateRect(hProgressParentWnd, NULL, FALSE), "GetUpdateRect: There should be a region that needs to be updated\n");
|
||||
flush_events();
|
||||
update_window(hProgressParentWnd);
|
||||
|
||||
SendMessageA(hProgressWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
|
||||
SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
|
||||
SendMessageA(hProgressWnd, PBM_SETSTEP, 20, 0);
|
||||
|
@ -166,15 +165,15 @@ static void test_redraw(void)
|
|||
/* PBM_SETPOS */
|
||||
ok(SendMessageA(hProgressWnd, PBM_SETPOS, 50, 0) == 10, "PBM_SETPOS must return the previous position\n");
|
||||
ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");
|
||||
|
||||
|
||||
/* PBM_DELTAPOS */
|
||||
ok(SendMessageA(hProgressWnd, PBM_DELTAPOS, 15, 0) == 50, "PBM_DELTAPOS must return the previous position\n");
|
||||
ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_DELTAPOS: The progress bar should be redrawn immediately\n");
|
||||
|
||||
|
||||
/* PBM_SETPOS */
|
||||
ok(SendMessageA(hProgressWnd, PBM_SETPOS, 80, 0) == 65, "PBM_SETPOS must return the previous position\n");
|
||||
ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");
|
||||
|
||||
|
||||
/* PBM_STEPIT */
|
||||
ok(SendMessageA(hProgressWnd, PBM_STEPIT, 0, 0) == 80, "PBM_STEPIT must return the previous position\n");
|
||||
ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_STEPIT: The progress bar should be redrawn immediately\n");
|
||||
|
@ -183,7 +182,7 @@ static void test_redraw(void)
|
|||
win_skip("PBM_GETPOS needs comctl32 > 4.70\n");
|
||||
else
|
||||
ok(ret == 100, "PBM_GETPOS returned a wrong position : %d\n", (UINT)ret);
|
||||
|
||||
|
||||
/* PBM_SETRANGE and PBM_SETRANGE32:
|
||||
Usually the progress bar doesn't repaint itself immediately. If the
|
||||
position is not in the new range, it does.
|
||||
|
@ -211,6 +210,8 @@ static void test_redraw(void)
|
|||
wine_dbgstr_rect(&last_paint_rect), wine_dbgstr_rect(&client_rect));
|
||||
update_window(hProgressWnd);
|
||||
ok(erased, "Progress bar should have erased the background\n");
|
||||
|
||||
DestroyWindow(hProgressWnd);
|
||||
}
|
||||
|
||||
static void test_setcolors(void)
|
||||
|
@ -241,12 +242,90 @@ static void test_setcolors(void)
|
|||
DestroyWindow(progress);
|
||||
}
|
||||
|
||||
static void test_PBM_STEPIT(void)
|
||||
{
|
||||
struct stepit_test
|
||||
{
|
||||
int min;
|
||||
int max;
|
||||
int step;
|
||||
} stepit_tests[] =
|
||||
{
|
||||
{ 3, 15, 5 },
|
||||
{ 3, 15, -5 },
|
||||
{ 3, 15, 50 },
|
||||
};
|
||||
HWND progress;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < sizeof(stepit_tests)/sizeof(stepit_tests[0]); i++)
|
||||
{
|
||||
struct stepit_test *test = &stepit_tests[i];
|
||||
LRESULT ret;
|
||||
|
||||
progress = create_progress(0);
|
||||
|
||||
ret = SendMessageA(progress, PBM_SETRANGE32, test->min, test->max);
|
||||
ok(ret != 0, "Unexpected return value.\n");
|
||||
|
||||
SendMessageA(progress, PBM_SETPOS, test->min, 0);
|
||||
SendMessageA(progress, PBM_SETSTEP, test->step, 0);
|
||||
|
||||
for (j = 0; j < test->max; j++)
|
||||
{
|
||||
int pos = SendMessageA(progress, PBM_GETPOS, 0, 0);
|
||||
int current;
|
||||
|
||||
pos += test->step;
|
||||
if (pos > test->max)
|
||||
pos = (pos - test->min) % (test->max - test->min) + test->min;
|
||||
if (pos < test->min)
|
||||
pos = (pos - test->min) % (test->max - test->min) + test->max;
|
||||
|
||||
SendMessageA(progress, PBM_STEPIT, 0, 0);
|
||||
|
||||
current = SendMessageA(progress, PBM_GETPOS, 0, 0);
|
||||
ok(current == pos, "Unexpected position %d, expected %d.\n", current, pos);
|
||||
}
|
||||
|
||||
DestroyWindow(progress);
|
||||
}
|
||||
}
|
||||
|
||||
static void init_functions(void)
|
||||
{
|
||||
HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
|
||||
|
||||
#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
|
||||
X(InitCommonControlsEx);
|
||||
#undef X
|
||||
}
|
||||
|
||||
START_TEST(progress)
|
||||
{
|
||||
INITCOMMONCONTROLSEX iccex;
|
||||
ULONG_PTR ctx_cookie;
|
||||
HANDLE hCtx;
|
||||
|
||||
init_functions();
|
||||
|
||||
iccex.dwSize = sizeof(iccex);
|
||||
iccex.dwICC = ICC_PROGRESS_CLASS;
|
||||
pInitCommonControlsEx(&iccex);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
test_redraw();
|
||||
test_setcolors();
|
||||
test_PBM_STEPIT();
|
||||
|
||||
if (!load_v6_module(&ctx_cookie, &hCtx))
|
||||
return;
|
||||
|
||||
test_setcolors();
|
||||
test_PBM_STEPIT();
|
||||
|
||||
unload_v6_module(ctx_cookie, hCtx);
|
||||
|
||||
cleanup();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue