user32: Improve the LoadImage() test.

Dmitry Timoshkov dmitry at codeweavers.com
Thu Nov 27 00:14:01 CST 2008


"Andrew Riedi" <andrewriedi at gmail.com> wrote:

> -    icon_entry->xHotspot = 1;
> -    icon_entry->yHotspot = 1;
> +    icon_entry->xHotspot = 1; /* Color planes for .ico. */
> +    icon_entry->yHotspot = ICON_BPP; /* BPP for .ico. */
...
>          ok(icon_info.xHotspot == 1, "xHotspot is %u.\n", icon_info.xHotspot);
> -        ok(icon_info.yHotspot == 1, "yHotspot is %u.\n", icon_info.yHotspot);
> +        ok(icon_info.yHotspot == 32, "yHotspot is %u.\n", icon_info.yHotspot);

It should be ICON_BPP instead of 32 for consistency.

> +    /* Test loading an icon as an icon. */
> +    SetLastError(0xdeadbeef);
> +    handle = LoadImageA(NULL, "icon.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
> +    ok(handle != NULL, "LoadImage() failed.\n");
> +    error = GetLastError();
> +    ok(error == 0 ||
> +        broken(error == 0xdeadbeef) || /* Win9x */
> +        broken(error == ERROR_BAD_PATHNAME), /* Win98, WinMe */
> +        "Last error: %u\n", error);

There is no point in testing last error value if the API didn't fail.

> +    /* Test the icon information. */
> +    SetLastError(0xdeadbeef);
> +    ret = GetIconInfo(handle, &icon_info);
> +    ok(ret, "GetIconInfo() failed.\n");
> +    error = GetLastError();
> +    ok(error == 0xdeadbeef, "Last error: %u\n", error);

Same here.

> +    if (ret)
> +    {
> +        ok(icon_info.fIcon == TRUE, "fIcon == FALSE.\n");
> +        ok(icon_info.xHotspot == 16, "xHotspot is %u.\n", icon_info.xHotspot);
> +        ok(icon_info.yHotspot == 16, "yHotspot is %u.\n", icon_info.yHotspot);
> +        ok(icon_info.hbmColor != NULL, "No hbmColor!\n");
> +        ok(icon_info.hbmMask != NULL, "No hbmMask!\n");
> +    }

'if (ret)' is useless if you don't expect a failure.

> +
> +    /* Clean up. */
> +    SetLastError(0xdeadbeef);
> +    ret = DestroyIcon(handle);
> +    ok(ret, "DestroyIcon() failed.\n");
> +    error = GetLastError();
> +    ok(error == 0xdeadbeef, "Last error: %u\n", error);

Same here.


-- 
Dmitry.



More information about the wine-devel mailing list