Skip to content

Commit 681d1df

Browse files
committed
[WIN32U_APITEST] Fix tests for NtGdiBitBlt
1 parent 4cf8777 commit 681d1df

1 file changed

Lines changed: 45 additions & 40 deletions

File tree

‎modules/rostests/apitests/win32u/ntgdi/NtGdiBitBlt.c‎

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,79 +16,85 @@ START_TEST(NtGdiBitBlt)
1616
DWORD bytes2[4] = {0x00000000, 0x0000000, 0x0000000, 0x00000000};
1717

1818
/* Test NULL dc */
19-
SetLastError(ERROR_SUCCESS);
19+
SetLastError(0xDEADBEEF);
2020
bRet = NtGdiBitBlt((HDC)0, 0, 0, 10, 10, (HDC)0, 10, 10, SRCCOPY, 0, 0);
2121
ok_int(bRet, FALSE);
22-
ok_long(GetLastError(), ERROR_SUCCESS);
22+
ok_long(GetLastError(), 0xDEADBEEF);
2323

2424
/* Test invalid dc */
25-
SetLastError(ERROR_SUCCESS);
25+
SetLastError(0xDEADBEEF);
2626
bRet = NtGdiBitBlt((HDC)0x123456, 0, 0, 10, 10, (HDC)0x123456, 10, 10, SRCCOPY, 0, 0);
2727
ok_int(bRet, FALSE);
28-
ok_long(GetLastError(), ERROR_SUCCESS);
28+
ok_long(GetLastError(), 0xDEADBEEF);
2929

3030
hdc1 = NtGdiCreateCompatibleDC(0);
3131
ok(hdc1 != NULL, "hdc1 was NULL.\n");
3232

3333
hdc2 = NtGdiCreateCompatibleDC(0);
3434
ok(hdc2 != NULL, "hdc2 was NULL.\n");
3535

36-
hbmp1 = NtGdiCreateBitmap(2, 2, 1, 32, (LPBYTE)bytes1 );
36+
BITMAPINFO bi = {0};
37+
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
38+
bi.bmiHeader.biWidth = 2;
39+
bi.bmiHeader.biHeight = -2; // top-down
40+
bi.bmiHeader.biPlanes = 1;
41+
bi.bmiHeader.biBitCount = 32;
42+
bi.bmiHeader.biCompression = BI_RGB;
43+
PVOID pvDibBits;
44+
45+
hbmp1 = CreateDIBSection(hdc1, &bi, DIB_RGB_COLORS, &pvDibBits, NULL, 0);
3746
ok(hbmp1 != NULL, "hbmp1 was NULL.\n");
47+
memcpy(pvDibBits, bytes1, sizeof(bytes1));
3848
hOldBmp1 = SelectObject(hdc1, hbmp1);
3949

40-
ok(NtGdiGetPixel(hdc1, 0, 0) == 0x000000ff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
41-
ok(NtGdiGetPixel(hdc1, 0, 1) == 0x00ff0000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
42-
ok(NtGdiGetPixel(hdc1, 1, 0) == 0x0000ff00, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
43-
ok(NtGdiGetPixel(hdc1, 1, 1) == 0x00ffffff, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
50+
ok_eq_hex(NtGdiGetPixel(hdc1, 0, 0), 0x000000ff);
51+
ok_eq_hex(NtGdiGetPixel(hdc1, 0, 1), 0x00ff0000);
52+
ok_eq_hex(NtGdiGetPixel(hdc1, 1, 0), 0x0000ff00);
53+
ok_eq_hex(NtGdiGetPixel(hdc1, 1, 1), 0x00ffffff);
4454

45-
hbmp2 = NtGdiCreateBitmap(2, 2, 1, 32, (LPBYTE)bytes2 );
55+
hbmp2 = CreateDIBSection(hdc2, &bi, DIB_RGB_COLORS, &pvDibBits, NULL, 0);
4656
ok(hbmp2 != NULL, "hbmp2 was NULL.\n");
57+
memcpy(pvDibBits, bytes2, sizeof(bytes1));
4758
hOldBmp2 = SelectObject(hdc2, hbmp2);
4859

4960
bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 0, 0, SRCCOPY, 0, 0);
5061
ok_int(bRet, TRUE);
51-
ok_long(GetLastError(), ERROR_SUCCESS);
52-
ok(NtGdiGetPixel(hdc2, 0, 0) == 0x00000000, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
53-
ok(NtGdiGetPixel(hdc2, 0, 1) == 0x00000000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
54-
ok(NtGdiGetPixel(hdc2, 1, 0) == 0x00000000, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
55-
ok(NtGdiGetPixel(hdc2, 1, 1) == 0x00000000, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
62+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x00000000);
63+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00000000);
64+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x00000000);
65+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00000000);
5666

5767
bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 1, 1, SRCCOPY, 0, 0);
5868
ok_int(bRet, TRUE);
59-
ok_long(GetLastError(), ERROR_SUCCESS);
60-
ok(NtGdiGetPixel(hdc2, 0, 0) == 0x000000ff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
61-
ok(NtGdiGetPixel(hdc2, 0, 1) == 0x00000000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
62-
ok(NtGdiGetPixel(hdc2, 1, 0) == 0x00000000, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
63-
ok(NtGdiGetPixel(hdc2, 1, 1) == 0x00000000, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
69+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x000000ff);
70+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00000000);
71+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x00000000);
72+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00000000);
6473

6574
NtGdiSetPixel(hdc2, 0, 0, 0x00000000);
6675

6776
bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 0, 0, SRCCOPY, 0, 0);
6877
ok_int(bRet, TRUE);
69-
ok_long(GetLastError(), ERROR_SUCCESS);
70-
ok(NtGdiGetPixel(hdc2, 0, 0) == 0x00000000, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
71-
ok(NtGdiGetPixel(hdc2, 0, 1) == 0x00000000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
72-
ok(NtGdiGetPixel(hdc2, 1, 0) == 0x00000000, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
73-
ok(NtGdiGetPixel(hdc2, 1, 1) == 0x00000000, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
78+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x00000000);
79+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00000000);
80+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x00000000);
81+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00000000);
7482

7583
bRet = NtGdiBitBlt(hdc2, 1, 1, -2, -2, hdc1, 2, 2, SRCCOPY, 0, 0);
7684
ok_int(bRet, TRUE);
77-
ok_long(GetLastError(), ERROR_SUCCESS);
78-
ok(NtGdiGetPixel(hdc2, 0, 0) == 0x00ffffff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
79-
ok(NtGdiGetPixel(hdc2, 0, 1) == 0x00000000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
80-
ok(NtGdiGetPixel(hdc2, 1, 0) == 0x00000000, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
81-
ok(NtGdiGetPixel(hdc2, 1, 1) == 0x00000000, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
85+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x00ffffff);
86+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00000000);
87+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x00000000);
88+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00000000);
8289

8390
NtGdiSetPixel(hdc2, 0, 0, 0x00000000);
8491

8592
bRet = NtGdiBitBlt(hdc2, 2, 2, -2, -2, hdc1, 2, 2, SRCCOPY, 0, 0);
8693
ok_int(bRet, TRUE);
87-
ok_long(GetLastError(), ERROR_SUCCESS);
88-
ok(NtGdiGetPixel(hdc2, 0, 0) == 0x000000ff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
89-
ok(NtGdiGetPixel(hdc2, 0, 1) == 0x00ff0000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
90-
ok(NtGdiGetPixel(hdc2, 1, 0) == 0x0000ff00, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
91-
ok(NtGdiGetPixel(hdc2, 1, 1) == 0x00ffffff, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
94+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x000000ff);
95+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00ff0000);
96+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x0000ff00);
97+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00ffffff);
9298

9399
NtGdiSetPixel(hdc2, 0, 0, 0x00000000);
94100
NtGdiSetPixel(hdc2, 1, 0, 0x00000000);
@@ -97,11 +103,10 @@ START_TEST(NtGdiBitBlt)
97103

98104
bRet = NtGdiBitBlt(hdc2, 0, 0, 2, 2, hdc1, 0, 0, SRCCOPY, 0, 0);
99105
ok_int(bRet, TRUE);
100-
ok_long(GetLastError(), ERROR_SUCCESS);
101-
ok(NtGdiGetPixel(hdc2, 0, 0) == 0x000000ff, "Pixel[0][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 0));
102-
ok(NtGdiGetPixel(hdc2, 0, 1) == 0x00ff0000, "Pixel[0][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 0, 1));
103-
ok(NtGdiGetPixel(hdc2, 1, 0) == 0x0000ff00, "Pixel[1][0] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 0));
104-
ok(NtGdiGetPixel(hdc2, 1, 1) == 0x00ffffff, "Pixel[1][1] 0x%08x\n", (UINT)NtGdiGetPixel(hdc2, 1, 1));
106+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 0), 0x000000ff);
107+
ok_eq_hex(NtGdiGetPixel(hdc2, 0, 1), 0x00ff0000);
108+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 0), 0x0000ff00);
109+
ok_eq_hex(NtGdiGetPixel(hdc2, 1, 1), 0x00ffffff);
105110

106111
SelectObject(hdc2, hOldBmp2);
107112
SelectObject(hdc1, hOldBmp1);

0 commit comments

Comments
 (0)