Fabian Maurer : comctl32/progress: Fix wrapping of values in PBM_STEPIT and add tests.
Alexandre Julliard
julliard at winehq.org
Tue Feb 27 17:29:34 CST 2018
Module: wine
Branch: master
Commit: 9036a84b0f119a32c8ee9d222a2c691cd144a186
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9036a84b0f119a32c8ee9d222a2c691cd144a186
Author: Fabian Maurer <dark.shadow4 at web.de>
Date: Tue Feb 27 13:43:13 2018 +0300
comctl32/progress: Fix wrapping of values in PBM_STEPIT and add tests.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 80cced4..28d9fd2 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 9dd4b55..d3b219c 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();
}
More information about the wine-cvs
mailing list