From: Fabian Maurer dark.shadow4@web.de
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
v4: fixed tests
dlls/comctl32/progress.c | 10 +++++++-- dlls/comctl32/tests/progress.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/progress.c b/dlls/comctl32/progress.c index 80cced4c66..28d9fd2fd3 100644 --- a/dlls/comctl32/progress.c +++ b/dlls/comctl32/progress.c @@ -655,8 +655,14 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, INT oldVal; oldVal = infoPtr->CurVal; infoPtr->CurVal += infoPtr->Step; - if(infoPtr->CurVal > infoPtr->MaxVal) - infoPtr->CurVal = infoPtr->MinVal; + if (infoPtr->CurVal > infoPtr->MaxVal) + { + infoPtr->CurVal = (infoPtr->CurVal - infoPtr->MinVal) % (infoPtr->MaxVal - infoPtr->MinVal) + infoPtr->MinVal; + } + if (infoPtr->CurVal < infoPtr->MinVal) + { + infoPtr->CurVal = (infoPtr->CurVal - infoPtr->MinVal) % (infoPtr->MaxVal - infoPtr->MinVal) + infoPtr->MaxVal; + } if(oldVal != infoPtr->CurVal) { TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal); diff --git a/dlls/comctl32/tests/progress.c b/dlls/comctl32/tests/progress.c index 9dd4b55202..d3b219ccca 100644 --- a/dlls/comctl32/tests/progress.c +++ b/dlls/comctl32/tests/progress.c @@ -237,6 +237,56 @@ 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"); @@ -260,6 +310,7 @@ START_TEST(progress)
test_redraw(); test_setcolors(); + test_PBM_STEPIT();
cleanup(); }