From: Jacob Czekalla jczekalla@codeweavers.com
--- dlls/comctl32/tests/progress.c | 100 ++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/progress.c b/dlls/comctl32/tests/progress.c index b6716366498..4bba4464518 100644 --- a/dlls/comctl32/tests/progress.c +++ b/dlls/comctl32/tests/progress.c @@ -23,16 +23,26 @@ #include "winbase.h" #include "wingdi.h" #include "winuser.h" -#include "commctrl.h" +#include "commctrl.h" +#include "vssym32.h"
#include "wine/test.h" - #include "v6util.h" +#include "msg.h"
static HWND hProgressParentWnd; static const char progressTestClass[] = "ProgressBarTestClass"; static BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
+/* For message tests */ +enum seq_index +{ + CHILD_SEQ_INDEX, + NUM_MSG_SEQUENCES +}; + +static struct msg_sequence *sequences[NUM_MSG_SEQUENCES]; + static HWND create_progress(DWORD style) { return CreateWindowExA(0, PROGRESS_CLASSA, "", WS_VISIBLE | style, @@ -308,6 +318,90 @@ static void test_PBM_STEPIT(void) } }
+static WNDPROC old_proc; + +static const struct message paint_pbm_setstate_seq[] = +{ + {PBM_SETSTATE, sent}, + {WM_PAINT, sent}, + {WM_ERASEBKGND, sent | defwinproc}, + {0} +}; + +static const struct message pbm_setstate_seq[] = +{ + {PBM_SETSTATE, sent}, + {0} +}; + +static LRESULT WINAPI test_pbm_setstate_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) +{ + static int defwndproc_counter = 0; + struct message msg = {0}; + LRESULT ret; + + if (message == PBM_SETSTATE + || message == WM_PAINT + || message == WM_ERASEBKGND) + { + msg.message = message; + msg.flags = sent | wparam | lparam; + if (defwndproc_counter) + msg.flags |= defwinproc; + msg.wParam = wp; + msg.lParam = lp; + add_message(sequences, CHILD_SEQ_INDEX, &msg); + } + + ++defwndproc_counter; + ret = CallWindowProcA(old_proc, hwnd, message, wp, lp); + --defwndproc_counter; + return ret; +} + +void test_bar_states(void) +{ + HWND progress_bar; + int state; + + static const struct + { + DWORD state; + DWORD previous_state; + const struct message *expected_seq; + BOOL error; + BOOL todo; + } + tests[] = + { + {0, PBST_NORMAL, pbm_setstate_seq, 1, 1}, + {PBST_NORMAL, PBST_NORMAL, pbm_setstate_seq, 0, 1}, + {PBST_PAUSED, PBST_NORMAL, paint_pbm_setstate_seq, 0, 1}, + {PBST_PAUSED, PBST_PAUSED, pbm_setstate_seq, 0, 1}, + {PBST_ERROR, PBST_PAUSED, paint_pbm_setstate_seq, 0, 1}, + {PBST_ERROR, PBST_ERROR, pbm_setstate_seq, 0, 1}, + {PBFS_PARTIAL, PBST_ERROR, pbm_setstate_seq, 1, 1} + }; + + progress_bar = create_progress(0); + + old_proc = (WNDPROC)SetWindowLongPtrA(progress_bar, GWLP_WNDPROC, (LONG_PTR)test_pbm_setstate_proc); + flush_events(); + flush_sequences(sequences, NUM_MSG_SEQUENCES); + + for (int i = 0; i < ARRAY_SIZE(tests); i++) + { + state = SendMessageA(progress_bar, PBM_SETSTATE, tests[i].state, 0); + flush_events(); + ok_sequence(sequences, CHILD_SEQ_INDEX, tests[i].expected_seq, "PBM_SETSTATE", tests[i].todo); + todo_wine_if(tests[i].todo) ok(state == (tests[i].error ? 0 : tests[i].previous_state), "Expected %ld, but got %d.\n", tests[i].previous_state, state); + state = SendMessageA(progress_bar, PBM_GETSTATE, 0, 0); + todo_wine_if(tests[i].todo) ok(state == (tests[i].error ? tests[i].previous_state : tests[i].state), "Expected %ld, but got %d.\n", tests[i].state, state); + } + + DestroyWindow(progress_bar); +} + static void init_functions(void) { HMODULE hComCtl32 = LoadLibraryA("comctl32.dll"); @@ -337,9 +431,11 @@ START_TEST(progress)
if (!load_v6_module(&ctx_cookie, &hCtx)) return; + init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
test_setcolors(); test_PBM_STEPIT(); + test_bar_states();
unload_v6_module(ctx_cookie, hCtx);