[PATCH 4/4] user32: Test the behavior of the clipboard with DIBs.
Charles Davis
cdavis5x at gmail.com
Tue May 3 14:03:26 CDT 2016
Signed-off-by: Charles Davis <cdavis5x at gmail.com>
---
dlls/user32/tests/clipboard.c | 372 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 371 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c
index be6c9bf..66db820 100644
--- a/dlls/user32/tests/clipboard.c
+++ b/dlls/user32/tests/clipboard.c
@@ -342,15 +342,176 @@ static HENHMETAFILE create_emf(void)
return CloseEnhMetaFile(hdc);
}
+static HGLOBAL create_handle(void *data, DWORD size)
+{
+ HGLOBAL h = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, size);
+ void *ptr;
+ if (!h) return NULL;
+ ptr = GlobalLock(h);
+ memcpy(ptr, data, size);
+ GlobalUnlock(h);
+ return h;
+}
+
+static HGLOBAL create_core_dib(void)
+{
+#include "pshpack1.h"
+ static struct {
+ BITMAPCOREHEADER header;
+ DWORD pixel;
+ } dib_info =
+ {
+ {
+ sizeof(dib_info.header),
+ 1, 1, /* width, height */
+ 1, /* planes */
+ 32 /* bits/pixel */
+ },
+ 0xe4
+ };
+#include "poppack.h"
+ return create_handle(&dib_info, sizeof(dib_info));
+}
+
+static HGLOBAL create_paletted_dib(void)
+{
+#include "pshpack1.h"
+ static struct {
+ BITMAPINFOHEADER header;
+ RGBQUAD colors[4];
+ BYTE pixel;
+ } dib_info =
+ {
+ {
+ sizeof(dib_info.header),
+ 2, 2, /* width, height */
+ 1, /* planes */
+ 2, /* bits/pixel */
+ BI_RGB, /* compression */
+ 1, /* image size */
+ 0, 0, /* physical resolution (x, y) */
+ 4, /* number of colors used */
+ 0 /* number of important colors (all) */
+ },
+ {
+ {0,0,0,0}, /* black */
+ {255,0,0,0}, /* red */
+ {0,255,0,0}, /* green */
+ {255,255,255,0} /* white */
+ },
+ 0xe4
+ };
+#include "poppack.h"
+ return create_handle(&dib_info, sizeof(dib_info));
+}
+
+static HGLOBAL create_dib(void)
+{
+#include "pshpack1.h"
+ static struct {
+ BITMAPINFOHEADER header;
+ DWORD masks[3];
+ DWORD pixel;
+ } dib_info =
+ {
+ {
+ sizeof(dib_info.header),
+ 1, 1, /* width, height */
+ 1, /* planes */
+ 32, /* bits/pixel */
+ BI_BITFIELDS, /* compression */
+ 4, /* image size */
+ 0, 0, /* physical resolution (x, y) */
+ 0, /* number of colors used */
+ 0 /* number of important colors */
+ },
+ { /* bitfield masks */
+ 0x0000ff00, /* red */
+ 0x00ff0000, /* green */
+ 0xff000000 /* blue */
+ },
+ 0
+ };
+#include "poppack.h"
+ return create_handle(&dib_info, sizeof(dib_info));
+}
+
+static HGLOBAL create_dibv4(void)
+{
+#include "pshpack1.h"
+ static struct {
+ BITMAPV4HEADER header;
+ DWORD pixel;
+ } dib_info =
+ {
+ {
+ sizeof(dib_info.header),
+ 1, 1, /* width, height */
+ 1, /* planes */
+ 32, /* bits/pixel */
+ BI_RGB, /* compression */
+ 4, /* image size */
+ 0, 0, /* physical resolution (x, y) */
+ 0, /* number of colors used */
+ 0, /* number of important colors (all) */
+ 0, 0, 0, 0, /* RGBA bitmasks (only if BI_BITFIELDS) */
+ LCS_sRGB, /* color-space type */
+ {{0,0,0},{0,0,0},{0,0,0}}, /* CIE endpoints */
+ 0, 0, 0 /* gamma curve (red, green, blue) */
+ },
+ 0
+ };
+#include "poppack.h"
+ return create_handle(&dib_info, sizeof(dib_info));
+}
+
+static HGLOBAL create_dibv5(void)
+{
+#include "pshpack1.h"
+ static struct {
+ BITMAPV5HEADER header;
+ DWORD pixel;
+ } dib_info =
+ {
+ {
+ sizeof(dib_info.header),
+ 1, 1, /* width, height */
+ 1, /* planes */
+ 32, /* bits/pixel */
+ BI_RGB, /* compression */
+ 4, /* image size */
+ 0, 0, /* physical resolution (x, y) */
+ 0, /* number of colors used */
+ 0, /* number of important colors (all) */
+ 0, 0, 0, 0, /* RGBA bitmasks (only if BI_BITFIELDS) */
+ LCS_sRGB, /* color-space type */
+ {{0,0,0},{0,0,0},{0,0,0}}, /* CIE endpoints */
+ 0, 0, 0, /* gamma curve (red, green, blue) */
+ LCS_GM_GRAPHICS, /* rendering intent */
+ 0, 0, /* color profile (none) */
+ 0
+ },
+ 0
+ };
+#include "poppack.h"
+ return create_handle(&dib_info, sizeof(dib_info));
+}
+
static void test_synthesized(void)
{
- HGLOBAL h, htext;
+ HGLOBAL h, htext, hcoredib, hpaldib, hdib, hdibv4, hdibv5;
HENHMETAFILE emf;
BOOL r;
UINT cf;
HANDLE data;
+ BITMAPV5HEADER *dibv5_hdr;
htext = create_text();
+ hcoredib = create_core_dib();
+ hpaldib = create_paletted_dib();
+ hdib = create_dib();
+ hdibv4 = create_dibv4();
+ hdibv5 = create_dibv5();
emf = create_emf();
r = OpenClipboard(NULL);
@@ -397,7 +558,216 @@ static void test_synthesized(void)
r = EmptyClipboard();
ok(r, "gle %d\n", GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ h = SetClipboardData(CF_DIB, hdib);
+ ok(h == hdib, "got %p, gle %d\n", h, GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ cf = EnumClipboardFormats(0);
+ ok(cf == CF_DIB, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_BITMAP, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_DIBV5, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+ dibv5_hdr = GlobalLock(data);
+ ok(dibv5_hdr->bV5Size == sizeof(BITMAPV5HEADER), "DIB header size is %u\n", dibv5_hdr->bV5Size);
+ ok(dibv5_hdr->bV5RedMask == 0x0000ff00, "red mask is %08x\n", dibv5_hdr->bV5RedMask);
+ ok(dibv5_hdr->bV5GreenMask == 0x00ff0000, "green mask is %08x\n", dibv5_hdr->bV5GreenMask);
+ ok(dibv5_hdr->bV5BlueMask == 0xff000000, "blue mask is %08x\n", dibv5_hdr->bV5BlueMask);
+ GlobalUnlock(data);
+
+ r = EmptyClipboard();
+ ok(r, "gle %d\n", GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ h = SetClipboardData(CF_DIB, hpaldib);
+ ok(h == hpaldib, "got %p, gle %d\n", h, GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ cf = EnumClipboardFormats(0);
+ ok(cf == CF_DIB, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_BITMAP, "cf %08x\n", cf);
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_DIBV5, "cf %08x\n", cf);
+
+ r = EmptyClipboard();
+ ok(r, "gle %d\n", GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ h = SetClipboardData(CF_DIB, hcoredib);
+ ok(h == hcoredib, "got %p, gle %d\n", h, GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ cf = EnumClipboardFormats(0);
+ ok(cf == CF_DIB, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_BITMAP, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_DIBV5, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+ dibv5_hdr = GlobalLock(data);
+ ok(dibv5_hdr->bV5Size == sizeof(BITMAPV5HEADER), "DIB header size is %u\n", dibv5_hdr->bV5Size);
+ ok(dibv5_hdr->bV5Width == 1, "DIB width is %u\n", dibv5_hdr->bV5Width);
+ ok(dibv5_hdr->bV5Height == 1, "DIB height is %u\n", dibv5_hdr->bV5Height);
+ ok(dibv5_hdr->bV5Planes == 1, "DIB # of planes is %u\n", dibv5_hdr->bV5Planes);
+ ok(dibv5_hdr->bV5BitCount == 32 || broken(dibv5_hdr->bV5BitCount == 24) /* win7 */,
+ "DIB bits/pixel is %u\n", dibv5_hdr->bV5BitCount);
+ GlobalUnlock(data);
+
+ r = EmptyClipboard();
+ ok(r, "gle %d\n", GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ h = SetClipboardData(CF_DIB, hdibv4);
+ ok(h == hdibv4, "got %p, gle %d\n", h, GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ cf = EnumClipboardFormats(0);
+ ok(cf == CF_DIB, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_BITMAP, "cf %08x\n", cf);
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_DIBV5, "cf %08x\n", cf);
+
+ r = EmptyClipboard();
+ ok(r, "gle %d\n", GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ h = SetClipboardData(CF_DIB, hdibv5);
+ ok(h == hdibv5, "got %p, gle %d\n", h, GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ cf = EnumClipboardFormats(0);
+ ok(cf == CF_DIB, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_BITMAP, "cf %08x\n", cf);
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_DIBV5, "cf %08x\n", cf);
+
+ r = EmptyClipboard();
+ ok(r, "gle %d\n", GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ hdib = create_dib();
+ hdibv5 = create_dibv5();
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ h = SetClipboardData(CF_DIBV5, hdibv5);
+ ok(h == hdibv5, "got %p, gle %d\n", h, GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ cf = EnumClipboardFormats(0);
+ ok(cf == CF_DIBV5, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_BITMAP, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_DIB, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+ dibv5_hdr = GlobalLock(data);
+ ok(dibv5_hdr->bV5Size == sizeof(BITMAPINFOHEADER), "DIB header size is %u\n", dibv5_hdr->bV5Size);
+ GlobalUnlock(data);
+
+ r = EmptyClipboard();
+ ok(r, "gle %d\n", GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ h = SetClipboardData(CF_DIBV5, hdib);
+ ok(h == hdib, "got %p, gle %d\n", h, GetLastError());
+ r = CloseClipboard();
+ ok(r, "gle %d\n", GetLastError());
+
+ r = OpenClipboard(NULL);
+ ok(r, "gle %d\n", GetLastError());
+ cf = EnumClipboardFormats(0);
+ ok(cf == CF_DIBV5, "cf %08x\n", cf);
+ data = GetClipboardData(cf);
+ ok(data != NULL, "couldn't get data\n");
+ dibv5_hdr = GlobalLock(data);
+ ok(dibv5_hdr->bV5Size == sizeof(BITMAPINFOHEADER), "DIB header size is %u\n", dibv5_hdr->bV5Size);
+ GlobalUnlock(data);
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_BITMAP, "cf %08x\n", cf);
+
+ cf = EnumClipboardFormats(cf);
+ ok(cf == CF_DIB, "cf %08x\n", cf);
+
+ r = EmptyClipboard();
+ ok(r, "gle %d\n", GetLastError());
r = CloseClipboard();
ok(r, "gle %d\n", GetLastError());
}
--
2.8.1
More information about the wine-patches
mailing list