Skip to content

Commit 2e206b1

Browse files
committed
[WIN32U_APITEST] Rewrite test for NtGdiExtTextOutW
1 parent 4671aaa commit 2e206b1

1 file changed

Lines changed: 79 additions & 22 deletions

File tree

modules/rostests/apitests/win32u/ntgdi/NtGdiExtTextOutW.c

Lines changed: 79 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,92 @@ NtGdiExtTextOutW(
2424

2525
START_TEST(NtGdiExtTextOutW)
2626
{
27-
HINSTANCE hinst = GetModuleHandle(NULL);
28-
HWND hWnd;
29-
HDC hDC;
30-
RECT rect;
31-
LPWSTR lpstr;
32-
BOOL ret;
33-
ULONG len;
27+
static const LPWSTR lpstr = L"Hallo";
28+
ULONG len = lstrlenW(lpstr);
29+
RECT rect = { 0, 0, 100, 100 };
3430
INT Dx[10] = {10, -5, 10, 5, 10, -10, 10, 5, 10, 5};
3531

36-
/* Create a window */
37-
hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
38-
CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
39-
NULL, NULL, hinst, 0);
40-
hDC = GetDC(hWnd);
32+
HDC hdc = CreateCompatibleDC(NULL);
33+
HBITMAP hbm = CreateCompatibleBitmap(hdc, 10, 10);
34+
SelectObject(hdc, hbm);
4135

42-
lpstr = L"Hallo";
43-
len = lstrlenW(lpstr);
36+
/* Test valid call */
37+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, &rect, lpstr, len, Dx, 0), 1);
4438

45-
ret = NtGdiExtTextOutW(hDC, 0, 0, 0, &rect, lpstr, len, Dx, 0);
46-
ok_int(ret, 1);
39+
/* Test NULL hdc */
40+
SetLastError(0xDEADFACE);
41+
ok_int(NtGdiExtTextOutW(NULL, 0, 0, 0, &rect, lpstr, len, Dx, 0), 0);
42+
ok_err(0xDEADFACE);
4743

48-
ret = NtGdiExtTextOutW(hDC, 0, 0, ETO_PDY, &rect, lpstr, len, Dx, 0);
49-
ok_int(ret, 1);
44+
/* Test NULL rect */
45+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, NULL, lpstr, len, Dx, 0), 1);
46+
47+
/* Test with invalid rect */
48+
RECT invalid_rect = { MAXLONG, MINLONG, MINLONG, MAXLONG };
49+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, &invalid_rect, lpstr, len, Dx, 0), 1);
50+
51+
/* Test NULL lpstr with zero len */
52+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, &rect, NULL, 0, Dx, 0), 1);
53+
54+
/* Test NULL lpstr with non-zero len */
55+
SetLastError(0xDEADFACE);
56+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, &rect, NULL, len, Dx, 0), 0);
57+
ok_err(0xDEADFACE);
58+
59+
/* Test NULL pdx and NULL lpstr with zero len */
60+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, &rect, NULL, 0, NULL, 0), 1);
61+
62+
/* Test NULL pdx and valid lpstr with zero len */
63+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, &rect, lpstr, 0, NULL, 0), 1);
64+
65+
/* Test NULL pdx and valid lpstr with non-zero len */
66+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, &rect, lpstr, len, NULL, 0), 1);
67+
68+
/* Test NULL pdx and ETO_PDY */
69+
if (GetNTVersion() <= _WIN32_WINNT_VISTA)
70+
{
71+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, ETO_PDY, &rect, lpstr, len, NULL, 0), 1);
72+
}
73+
else
74+
{
75+
SetLastError(0xDEADFACE);
76+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, ETO_PDY, &rect, lpstr, len, NULL, 0), 0);
77+
ok_err(ERROR_INVALID_PARAMETER);
78+
}
79+
80+
/* Test different flOpts */
81+
SetLastError(0xDEADFACE);
82+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000001, &rect, lpstr, len, Dx, 0), 0); // ETO_GRAYED
83+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000002, &rect, lpstr, len, Dx, 0), 1); // ETO_OPAQUE
84+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000005, &rect, lpstr, len, Dx, 0), 0); // ETO_OPAQUE | ETO_GRAYED
85+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000004, &rect, lpstr, len, Dx, 0), 1); // ETO_CLIPPED
86+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000008, &rect, lpstr, len, Dx, 0), 0);
87+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000010, &rect, lpstr, len, Dx, 0), 1); // ETO_GLYPH_INDEX
88+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000020, &rect, lpstr, len, Dx, 0), 0);
89+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000040, &rect, lpstr, len, Dx, 0), 0);
90+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000080, &rect, lpstr, len, Dx, 0), 1); // ETO_RTLREADING
91+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000100, &rect, lpstr, len, Dx, 0), 0);
92+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000200, &rect, lpstr, len, Dx, 0), 0);
93+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000400, &rect, lpstr, len, Dx, 0), 1); // ETO_NUMERICSLOCAL
94+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00000800, &rect, lpstr, len, Dx, 0), 1); // ETO_NUMERICSLATIN
95+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00001000, &rect, lpstr, len, Dx, 0), 1); // ETO_IGNORELANGUAGE
96+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00002000, &rect, lpstr, len, Dx, 0), 1); // ETO_PDY
97+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00004000, &rect, lpstr, len, Dx, 0), 0);
98+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00008000, &rect, lpstr, len, Dx, 0), 0);
99+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00010000, &rect, lpstr, len, Dx, 0), 0); // ETO_REVERSE_INDEX_MAP
100+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0x00020000, &rect, lpstr, len, Dx, 0), 0);
101+
ok_err(0xDEADFACE);
50102

51103
/* Test invalid lpDx */
52-
ret = NtGdiExtTextOutW(hDC, 0, 0, 0, 0, lpstr, len, (INT*)((ULONG_PTR)-1), 0);
53-
ok_int(ret, 0);
104+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, 0, lpstr, len, (INT*)((ULONG_PTR)-1), 0), 0);
54105

55106
/* Test alignment requirement for lpDx */
56-
ret = NtGdiExtTextOutW(hDC, 0, 0, 0, 0, lpstr, len, (INT*)((ULONG_PTR)Dx + 1), 0);
57-
ok_int(ret, 0);
107+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, 0, lpstr, len, (INT*)((ULONG_PTR)Dx + 1), 0),
108+
(GetNTVersion() >= _WIN32_WINNT_WIN10) ? 1 : 0);
109+
110+
/* Test invalid codepage */
111+
ok_int(NtGdiExtTextOutW(hdc, 0, 0, 0, &rect, lpstr, len, Dx, 0xDEADCAFE), 1);
112+
113+
DeleteDC(hdc);
114+
DeleteObject(hbm);
58115
}

0 commit comments

Comments
 (0)