[PATCH] user32: Add tests showing that MapWindowPoints, ClientToScreen and ScreenToClient never fail.

Rico Schüller kgbricola at web.de
Tue Oct 16 14:31:56 CDT 2012


On 16.10.2012 20:21, Henri Verbeet wrote:
> On 16 October 2012 20:12, Christian Costa <titan.costa at gmail.com> wrote:
>> +    //SetWindowPos(wnd, NULL, 0, 0, rect.right / 2, rect.bottom / 2, 0);
> C99 comment.
>
> I don't think these are very interesting cases though, it's probably
> more interesting what happens with e.g. a destroyed window, or a
> fullscreen window.
>
>
>

The interesting cases are likely:
     ret = ScreenToClient(NULL, NULL);
     ok(ret == FALSE, "Failed\n");

     /* invalid handle */
     ret = ScreenToClient(0xdeadbeef, &p);
     ok(ret == FALSE, "Failed\n");

     p.x = p.y = 100;
     ret = ScreenToClient(NULL, &p);
     ok(ret == FALSE, "Failed\n");
     ok(p.x == 100 && p.y == 100, "Failed\n");

     p.x = p.y = 0;
     ret = ScreenToClient(NULL, &p);
     ok(ret == FALSE, "Failed\n");
     ok(p.x == 0 && p.y == 0, "Failed\n");

     /* create test window */
     wnd = CreateWindow("static", "test", 100, 200, 150, 150, 0, NULL, 
NULL, NULL, NULL);

     ret = ScreenToClient(wnd, NULL);
     ok(ret == FALSE, "Failed\n");

     wnd = CreateWindowA("static", NULL, 0, 0, 0, rect.right / 2, 
rect.bottom / 2, 0, 0, 0, 0);
     p.x = p.y = 0;
     ret = ScreenToClient(wnd, &p);
     ok(...);
     ok(...);


And the implementation:
BOOL WINAPI ScreenToClient( HWND hwnd, LPPOINT lppnt )
{
     /* !hwnd is redundant, but faster, MapWindowPoints(0, 0, ...) will 
return 0 */
     if (!hwnd || !lppnt) return FALSE;
     return MapWindowPoints( 0, hwnd, lppnt, 1 ) != 0;
}

If I remember correctly, the game passes some NULL hwnd and invalid hwnd in.

Cheers
Rico



More information about the wine-devel mailing list