ReactOS  0.4.14-dev-337-gf981a68
console.c File Reference
#include "wine/test.h"
#include <windows.h>
#include <stdio.h>
Include dependency graph for console.c:

Go to the source code of this file.

Macros

#define TEST_ATTRIB   (BACKGROUND_BLUE | FOREGROUND_GREEN)
 
#define DEFAULT_ATTRIB   (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED)
 
#define CONTENT(c)   ('A' + (((c).Y * 17 + (c).X) % 23))
 
#define okCURSOR(hCon, c)
 
#define okCHAR(hCon, c, ch, attr)
 
#define KERNEL32_GET_PROC(func)
 
#define W   11
 
#define H   7
 
#define IN_SRECT(r, c)   ((r).Left <= (c).X && (c).X <= (r).Right && (r).Top <= (c).Y && (c).Y <= (r).Bottom)
 
#define IN_SRECT2(r, d, c)   ((d).X <= (c).X && (c).X <= (d).X + (r).Right - (r).Left && (d).Y <= (c).Y && (c).Y <= (d).Y + (r).Bottom - (r).Top)
 

Functions

static BOOL (WINAPI *pGetConsoleInputExeNameA)(DWORD
 
static DWORD (WINAPI *pGetConsoleProcessList)(LPDWORD
 
static HANDLE (WINAPI *pOpenConsoleW)(LPCWSTR
 
static void init_function_pointers (void)
 
static void resetContent (HANDLE hCon, COORD sbSize, BOOL content)
 
static void testCursor (HANDLE hCon, COORD sbSize)
 
static void testCursorInfo (HANDLE hCon)
 
static void testEmptyWrite (HANDLE hCon)
 
static void testWriteSimple (HANDLE hCon)
 
static void testWriteNotWrappedNotProcessed (HANDLE hCon, COORD sbSize)
 
static void testWriteNotWrappedProcessed (HANDLE hCon, COORD sbSize)
 
static void testWriteWrappedNotProcessed (HANDLE hCon, COORD sbSize)
 
static void testWriteWrappedProcessed (HANDLE hCon, COORD sbSize)
 
static void testWrite (HANDLE hCon, COORD sbSize)
 
static void testScroll (HANDLE hCon, COORD sbSize)
 
static BOOL WINAPI mch (DWORD event)
 
static void testCtrlHandler (void)
 
static void testScreenBuffer (HANDLE hConOut)
 
static void CALLBACK signaled_function (void *p, BOOLEAN timeout)
 
static void testWaitForConsoleInput (HANDLE input_handle)
 
static void test_GetSetConsoleInputExeName (void)
 
static void test_GetConsoleProcessList (void)
 
static void test_OpenCON (void)
 
static void test_OpenConsoleW (void)
 
static void test_CreateFileW (void)
 
static void test_VerifyConsoleIoHandle (HANDLE handle)
 
static void test_GetSetStdHandle (void)
 
static void test_GetNumberOfConsoleInputEvents (HANDLE input_handle)
 
static void test_WriteConsoleInputA (HANDLE input_handle)
 
static void test_WriteConsoleInputW (HANDLE input_handle)
 
static void test_WriteConsoleOutputCharacterA (HANDLE output_handle)
 
static void test_WriteConsoleOutputCharacterW (HANDLE output_handle)
 
static void test_WriteConsoleOutputAttribute (HANDLE output_handle)
 
static void test_FillConsoleOutputCharacterA (HANDLE output_handle)
 
static void test_FillConsoleOutputCharacterW (HANDLE output_handle)
 
static void test_FillConsoleOutputAttribute (HANDLE output_handle)
 
static void test_ReadConsoleOutputCharacterA (HANDLE output_handle)
 
static void test_ReadConsoleOutputCharacterW (HANDLE output_handle)
 
static void test_ReadConsoleOutputAttribute (HANDLE output_handle)
 
static void test_ReadConsole (void)
 
static void test_GetCurrentConsoleFont (HANDLE std_output)
 
static void test_GetConsoleFontSize (HANDLE std_output)
 
static void test_GetLargestConsoleWindowSize (HANDLE std_output)
 
static void test_GetConsoleFontInfo (HANDLE std_output)
 
static void test_SetConsoleFont (HANDLE std_output)
 
static void test_GetConsoleScreenBufferInfoEx (HANDLE std_output)
 
 START_TEST (console)
 

Variables

static LPSTR
 
static DWORD
 
static BOOL
 
static int mch_count
 
static HANDLE mch_event
 

Macro Definition Documentation

◆ CONTENT

#define CONTENT (   c)    ('A' + (((c).Y * 17 + (c).X) % 23))

Definition at line 41 of file console.c.

◆ DEFAULT_ATTRIB

Definition at line 37 of file console.c.

◆ H

#define H   7

◆ IN_SRECT

#define IN_SRECT (   r,
  c 
)    ((r).Left <= (c).X && (c).X <= (r).Right && (r).Top <= (c).Y && (c).Y <= (r).Bottom)

◆ IN_SRECT2

#define IN_SRECT2 (   r,
  d,
  c 
)    ((d).X <= (c).X && (c).X <= (d).X + (r).Right - (r).Left && (d).Y <= (c).Y && (c).Y <= (d).Y + (r).Bottom - (r).Top)

◆ KERNEL32_GET_PROC

#define KERNEL32_GET_PROC (   func)
Value:
p##func = (void *)GetProcAddress(hKernel32, #func); \
if(!p##func) trace("GetProcAddress(hKernel32, '%s') failed\n", #func);
GLenum func
Definition: glext.h:6028
#define trace
Definition: atltest.h:70
#define GetProcAddress(x, y)
Definition: compat.h:418
GLfloat GLfloat p
Definition: glext.h:8902

◆ okCHAR

#define okCHAR (   hCon,
  c,
  ch,
  attr 
)
Value:
do { \
char __ch; WORD __attr; DWORD __len; BOOL expect; \
expect = ReadConsoleOutputCharacterA((hCon), &__ch, 1, (c), &__len) == 1 && __len == 1 && __ch == (ch); \
ok(expect, "At (%d,%d): expecting char '%c'/%02x got '%c'/%02x\n", (c).X, (c).Y, (ch), (ch), __ch, __ch); \
expect = ReadConsoleOutputAttribute((hCon), &__attr, 1, (c), &__len) == 1 && __len == 1 && __attr == (attr); \
ok(expect, "At (%d,%d): expecting attr %04x got %04x\n", (c).X, (c).Y, (attr), __attr); \
} while (0)
#define Y(I)
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputCharacterA(IN HANDLE hConsoleOutput, OUT LPSTR lpCharacter, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCharsRead)
Definition: readwrite.c:1403
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputAttribute(IN HANDLE hConsoleOutput, OUT LPWORD lpAttribute, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfAttrsRead)
Definition: readwrite.c:1424
const GLubyte * c
Definition: glext.h:8905
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: cookie.c:170
__u8 attr
Definition: mkdosfs.c:359
#define expect(expected, got)
Definition: combo.c:36

Definition at line 51 of file console.c.

◆ okCURSOR

#define okCURSOR (   hCon,
  c 
)
Value:
do { \
CONSOLE_SCREEN_BUFFER_INFO __sbi; \
BOOL expect = GetConsoleScreenBufferInfo((hCon), &__sbi) && \
__sbi.dwCursorPosition.X == (c).X && __sbi.dwCursorPosition.Y == (c).Y; \
ok(expect, "Expected cursor at (%d,%d), got (%d,%d)\n", \
(c).X, (c).Y, __sbi.dwCursorPosition.X, __sbi.dwCursorPosition.Y); \
} while (0)
#define Y(I)
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
const GLubyte * c
Definition: glext.h:8905
#define expect(expected, got)
Definition: combo.c:36
#define c
Definition: ke_i.h:80

Definition at line 43 of file console.c.

◆ TEST_ATTRIB

#define TEST_ATTRIB   (BACKGROUND_BLUE | FOREGROUND_GREEN)

Definition at line 36 of file console.c.

◆ W

#define W   11

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pGetConsoleInputExeNameA)
static

◆ DWORD()

static DWORD ( WINAPI pGetConsoleProcessList)
static

◆ HANDLE()

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 59 of file console.c.

60 {
61  HMODULE hKernel32;
62 
63 #define KERNEL32_GET_PROC(func) \
64  p##func = (void *)GetProcAddress(hKernel32, #func); \
65  if(!p##func) trace("GetProcAddress(hKernel32, '%s') failed\n", #func);
66 
67  hKernel32 = GetModuleHandleA("kernel32.dll");
73 
74 #undef KERNEL32_GET_PROC
75 }
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameA(IN DWORD nBufferLength, OUT LPSTR lpExeName)
Definition: console.c:2945
DWORD WINAPI GetConsoleProcessList(LPDWORD lpdwProcessList, DWORD dwProcessCount)
Definition: console.c:2512
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
#define KERNEL32_GET_PROC(func)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleInputExeNameA(IN LPCSTR lpExeName)
Definition: console.c:2830
HANDLE WINAPI OpenConsoleW(LPCWSTR wsName, DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwShareMode)
Definition: console.c:791

Referenced by START_TEST().

◆ mch()

static BOOL WINAPI mch ( DWORD  event)
static

Definition at line 645 of file console.c.

646 {
647  mch_count++;
649  return TRUE;
650 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
static HANDLE mch_event
Definition: console.c:644
static int mch_count
Definition: console.c:639

Referenced by testCtrlHandler().

◆ resetContent()

static void resetContent ( HANDLE  hCon,
COORD  sbSize,
BOOL  content 
)
static

Definition at line 78 of file console.c.

79 {
80  COORD c;
82  char ch;
83  DWORD len;
84 
85  for (c.X = 0; c.X < sbSize.X; c.X++)
86  {
87  for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
88  {
89  ch = (content) ? CONTENT(c) : ' ';
90  WriteConsoleOutputAttribute(hCon, &attr, 1, c, &len);
91  WriteConsoleOutputCharacterA(hCon, &ch, 1, c, &len);
92  }
93  }
94 }
content
Definition: atl_ax.c:993
#define CONTENT(c)
Definition: console.c:41
BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:356
ULONG X
Definition: bl.h:1340
const GLubyte * c
Definition: glext.h:8905
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: cookie.c:170
GLenum GLsizei len
Definition: glext.h:6722
Definition: bl.h:1338
#define c
Definition: ke_i.h:80
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN CONST WORD *lpAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: readwrite.c:1655
ULONG Y
Definition: bl.h:1341
#define DEFAULT_ATTRIB
Definition: console.c:37

Referenced by testScroll(), and testWrite().

◆ signaled_function()

static void CALLBACK signaled_function ( void p,
BOOLEAN  timeout 
)
static

Definition at line 911 of file console.c.

912 {
913  HANDLE event = p;
914  SetEvent(event);
915  ok(!timeout, "wait shouldn't have timed out\n");
916 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
Definition: dhcpd.h:245
struct _cl_event * event
Definition: glext.h:7739
#define ok(value,...)
Definition: atltest.h:57
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by testWaitForConsoleInput().

◆ START_TEST()

START_TEST ( console  )

Definition at line 3022 of file console.c.

3023 {
3024  static const char font_name[] = "Lucida Console";
3025  HANDLE hConIn, hConOut;
3026  BOOL ret;
3028  LONG err;
3029  HKEY console_key;
3030  char old_font[LF_FACESIZE];
3031  BOOL delete = FALSE;
3032  DWORD size;
3033 
3035 
3036  /* be sure we have a clean console (and that's our own)
3037  * FIXME: this will make the test fail (currently) if we don't run
3038  * under X11
3039  * Another solution would be to rerun the test under wineconsole with
3040  * the curses backend
3041  */
3042 
3043  /* ReadConsoleOutputW doesn't retrieve characters from the output buffer
3044  * correctly for characters that don't have a glyph in the console font. So,
3045  * we first set the console font to Lucida Console (which has a wider
3046  * selection of glyphs available than the default raster fonts). We want
3047  * to be able to restore the original font afterwards, so don't change
3048  * if we can't read the original font.
3049  */
3050  err = RegOpenKeyExA(HKEY_CURRENT_USER, "Console", 0,
3051  KEY_QUERY_VALUE | KEY_SET_VALUE, &console_key);
3052  if (err == ERROR_SUCCESS)
3053  {
3054  size = sizeof(old_font);
3055  err = RegQueryValueExA(console_key, "FaceName", NULL, NULL,
3056  (LPBYTE) old_font, &size);
3058  {
3059  delete = (err == ERROR_FILE_NOT_FOUND);
3060  err = RegSetValueExA(console_key, "FaceName", 0, REG_SZ,
3061  (const BYTE *) font_name, sizeof(font_name));
3062  if (err != ERROR_SUCCESS)
3063  trace("Unable to change default console font, error %d\n", err);
3064  }
3065  else
3066  {
3067  trace("Unable to query default console font, error %d\n", err);
3068  RegCloseKey(console_key);
3069  console_key = NULL;
3070  }
3071  }
3072  else
3073  {
3074  trace("Unable to open HKCU\\Console, error %d\n", err);
3075  console_key = NULL;
3076  }
3077 
3078  /* Now detach and open a fresh console to play with */
3079  FreeConsole();
3080  ok(AllocConsole(), "Couldn't alloc console\n");
3081 
3082  /* Restore default console font if needed */
3083  if (console_key != NULL)
3084  {
3085  if (delete)
3086  err = RegDeleteValueA(console_key, "FaceName");
3087  else
3088  err = RegSetValueExA(console_key, "FaceName", 0, REG_SZ,
3089  (const BYTE *) old_font, strlen(old_font) + 1);
3090  ok(err == ERROR_SUCCESS, "Unable to restore default console font, error %d\n", err);
3091  }
3092  hConIn = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
3093  hConOut = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
3094 
3095  /* now verify everything's ok */
3096  ok(hConIn != INVALID_HANDLE_VALUE, "Opening ConIn\n");
3097  ok(hConOut != INVALID_HANDLE_VALUE, "Opening ConOut\n");
3098 
3099  ret = GetConsoleScreenBufferInfo(hConOut, &sbi);
3100  ok(ret, "Getting sb info\n");
3101  if (!ret) return;
3102 
3103  /* Reduce the size of the buffer to the visible area plus 3 lines to speed
3104  * up the tests.
3105  */
3106  trace("Visible area: %dx%d - %dx%d Buffer size: %dx%d\n", sbi.srWindow.Left, sbi.srWindow.Top, sbi.srWindow.Right, sbi.srWindow.Bottom, sbi.dwSize.X, sbi.dwSize.Y);
3107  sbi.dwSize.Y = size = (sbi.srWindow.Bottom + 1) + 3;
3108  ret = SetConsoleScreenBufferSize(hConOut, sbi.dwSize);
3109  ok(ret, "Setting sb info\n");
3110  ret = GetConsoleScreenBufferInfo(hConOut, &sbi);
3111  ok(ret, "Getting sb info\n");
3112  ok(sbi.dwSize.Y == size, "Unexpected buffer size: %d instead of %d\n", sbi.dwSize.Y, size);
3113  if (!ret) return;
3114 
3115  test_ReadConsole();
3116  /* Non interactive tests */
3117  testCursor(hConOut, sbi.dwSize);
3118  /* test parameters (FIXME: test functionality) */
3119  testCursorInfo(hConOut);
3120  /* will test wrapped (on/off) & processed (on/off) strings output */
3121  testWrite(hConOut, sbi.dwSize);
3122  /* will test line scrolling at the bottom of the screen */
3123  /* testBottomScroll(); */
3124  /* will test all the scrolling operations */
3125  testScroll(hConOut, sbi.dwSize);
3126  /* will test sb creation / modification / codepage handling */
3127  testScreenBuffer(hConOut);
3128  /* Test waiting for a console handle */
3129  testWaitForConsoleInput(hConIn);
3130 
3131  /* clear duplicated console font table */
3132  CloseHandle(hConIn);
3133  CloseHandle(hConOut);
3134  FreeConsole();
3135  ok(AllocConsole(), "Couldn't alloc console\n");
3136  hConIn = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
3137  hConOut = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
3138  ok(hConIn != INVALID_HANDLE_VALUE, "Opening ConIn\n");
3139  ok(hConOut != INVALID_HANDLE_VALUE, "Opening ConOut\n");
3140 
3141  testCtrlHandler();
3142  /* still to be done: access rights & access on objects */
3143 
3144  if (!pGetConsoleInputExeNameA || !pSetConsoleInputExeNameA)
3145  win_skip("GetConsoleInputExeNameA and/or SetConsoleInputExeNameA is not available\n");
3146  else
3148 
3151  test_CreateFileW();
3152  test_OpenCON();
3153  test_VerifyConsoleIoHandle(hConOut);
3156  test_WriteConsoleInputA(hConIn);
3157  test_WriteConsoleInputW(hConIn);
3167  test_GetCurrentConsoleFont(hConOut);
3168  test_GetConsoleFontSize(hConOut);
3170  test_GetConsoleFontInfo(hConOut);
3171  test_SetConsoleFont(hConOut);
3173 }
static void test_GetConsoleScreenBufferInfoEx(HANDLE std_output)
Definition: console.c:2973
static void test_GetCurrentConsoleFont(HANDLE std_output)
Definition: console.c:2623
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
static void test_ReadConsoleOutputCharacterA(HANDLE output_handle)
Definition: console.c:2324
BOOL WINAPI AllocConsole(VOID)
Definition: console.c:48
#define CloseHandle
Definition: compat.h:406
#define LF_FACESIZE
Definition: dimm.idl:39
static void test_GetConsoleFontInfo(HANDLE std_output)
Definition: console.c:2814
#define ERROR_SUCCESS
Definition: deptool.c:10
static void test_WriteConsoleOutputCharacterA(HANDLE output_handle)
Definition: console.c:1891
#define KEY_SET_VALUE
Definition: nt_native.h:1017
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
static void testCtrlHandler(void)
Definition: console.c:652
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
static void test_GetLargestConsoleWindowSize(HANDLE std_output)
Definition: console.c:2742
static void test_SetConsoleFont(HANDLE std_output)
Definition: console.c:2932
static void test_WriteConsoleInputA(HANDLE input_handle)
Definition: console.c:1417
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize)
Definition: console.c:1857
static void test_GetConsoleFontSize(HANDLE std_output)
Definition: console.c:2688
static void testWaitForConsoleInput(HANDLE input_handle)
Definition: console.c:918
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
static void test_WriteConsoleOutputAttribute(HANDLE output_handle)
Definition: console.c:2059
static void test_WriteConsoleOutputCharacterW(HANDLE output_handle)
Definition: console.c:1975
static void test_GetSetConsoleInputExeName(void)
Definition: console.c:963
static void testWrite(HANDLE hCon, COORD sbSize)
Definition: console.c:459
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define OPEN_EXISTING
Definition: compat.h:434
static void test_OpenCON(void)
Definition: console.c:1069
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
static void test_GetSetStdHandle(void)
Definition: console.c:1328
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
BOOL WINAPI FreeConsole(VOID)
Definition: console.c:105
static void testScreenBuffer(HANDLE hConOut)
Definition: console.c:695
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
SHORT Bottom
Definition: blue.h:28
static void test_GetConsoleProcessList(void)
Definition: console.c:1009
static void test_GetNumberOfConsoleInputEvents(HANDLE input_handle)
Definition: console.c:1364
static void test_OpenConsoleW(void)
Definition: console.c:1100
unsigned long DWORD
Definition: ntddk_ex.h:95
SHORT Top
Definition: blue.h:26
int ret
unsigned char BYTE
Definition: mem.h:68
static void test_WriteConsoleInputW(HANDLE input_handle)
Definition: console.c:1654
#define GENERIC_READ
Definition: compat.h:124
#define err(...)
static void testCursor(HANDLE hCon, COORD sbSize)
Definition: console.c:96
static void test_FillConsoleOutputCharacterA(HANDLE output_handle)
Definition: console.c:2142
static void init_function_pointers(void)
Definition: console.c:59
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define ok(value,...)
Definition: atltest.h:57
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2319
static void testCursorInfo(HANDLE hCon)
Definition: console.c:139
static void test_ReadConsole(void)
Definition: console.c:2575
static void test_FillConsoleOutputAttribute(HANDLE output_handle)
Definition: console.c:2260
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
SHORT Right
Definition: blue.h:27
static void test_CreateFileW(void)
Definition: console.c:1218
static void test_ReadConsoleOutputAttribute(HANDLE output_handle)
Definition: console.c:2492
static void test_ReadConsoleOutputCharacterW(HANDLE output_handle)
Definition: console.c:2408
ULONG Y
Definition: bl.h:1341
#define win_skip
Definition: test.h:141
static void testScroll(HANDLE hCon, COORD sbSize)
Definition: console.c:477
static void test_VerifyConsoleIoHandle(HANDLE handle)
Definition: console.c:1279
#define REG_SZ
Definition: layer.c:22
static void test_FillConsoleOutputCharacterW(HANDLE output_handle)
Definition: console.c:2201

◆ test_CreateFileW()

static void test_CreateFileW ( void  )
static

Definition at line 1218 of file console.c.

1219 {
1220  static const WCHAR coninW[] = {'C','O','N','I','N','$',0};
1221  static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0};
1222 
1223  static const struct
1224  {
1225  LPCWSTR name;
1226  DWORD access;
1227  BOOL inherit;
1228  DWORD creation;
1229  DWORD gle;
1230  BOOL is_broken;
1231  } cf_table[] = {
1232  {coninW, 0, FALSE, 0, ERROR_INVALID_PARAMETER, TRUE},
1233  {coninW, 0, FALSE, OPEN_ALWAYS, 0, FALSE},
1235  {coninW, GENERIC_READ | GENERIC_WRITE, FALSE, CREATE_NEW, 0, FALSE},
1237  {coninW, GENERIC_READ | GENERIC_WRITE, FALSE, OPEN_ALWAYS, 0, FALSE},
1238  {conoutW, 0, FALSE, 0, ERROR_INVALID_PARAMETER, TRUE},
1239  {conoutW, 0, FALSE, OPEN_ALWAYS, 0, FALSE},
1241  {conoutW, GENERIC_READ | GENERIC_WRITE, FALSE, CREATE_NEW, 0, FALSE},
1242  {conoutW, GENERIC_READ | GENERIC_WRITE, FALSE, CREATE_ALWAYS, 0, FALSE},
1243  {conoutW, GENERIC_READ | GENERIC_WRITE, FALSE, OPEN_ALWAYS, 0, FALSE},
1244  /* TRUNCATE_EXISTING is forbidden starting with Windows 8 */
1245  };
1246 
1247  int index;
1248  HANDLE ret;
1250 
1251  for (index = 0; index < sizeof(cf_table)/sizeof(cf_table[0]); index++)
1252  {
1253  SetLastError(0xdeadbeef);
1254 
1255  sa.nLength = sizeof(sa);
1256  sa.lpSecurityDescriptor = NULL;
1257  sa.bInheritHandle = cf_table[index].inherit;
1258 
1259  ret = CreateFileW(cf_table[index].name, cf_table[index].access,
1261  cf_table[index].creation, FILE_ATTRIBUTE_NORMAL, NULL);
1262  if (ret == INVALID_HANDLE_VALUE)
1263  {
1264  ok(cf_table[index].gle,
1265  "Expected CreateFileW not to return INVALID_HANDLE_VALUE for index %d\n", index);
1266  ok(GetLastError() == cf_table[index].gle,
1267  "Expected GetLastError() to return %u for index %d, got %u\n",
1268  cf_table[index].gle, index, GetLastError());
1269  }
1270  else
1271  {
1272  ok(!cf_table[index].gle || broken(cf_table[index].is_broken) /* Win7 */,
1273  "Expected CreateFileW to succeed for index %d\n", index);
1274  CloseHandle(ret);
1275  }
1276  }
1277 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#define OPEN_ALWAYS
Definition: disk.h:70
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define index(s, c)
Definition: various.h:29
#define GENERIC_READ
Definition: compat.h:124
#define broken(x)
Definition: _sntprintf.h:21
#define CREATE_ALWAYS
Definition: disk.h:72
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
#define ok(value,...)
Definition: atltest.h:57
#define CreateFileW
Definition: compat.h:408
Definition: name.c:36
#define CREATE_NEW
Definition: disk.h:69
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by START_TEST().

◆ test_FillConsoleOutputAttribute()

static void test_FillConsoleOutputAttribute ( HANDLE  output_handle)
static

Definition at line 2260 of file console.c.

2261 {
2262  COORD origin = {0, 0};
2263  DWORD count;
2264  BOOL ret;
2265  int i;
2266 
2267  const struct
2268  {
2269  HANDLE hConsoleOutput;
2270  WORD attr;
2271  DWORD length;
2272  COORD coord;
2273  LPDWORD lpNumAttrsWritten;
2274  DWORD last_error;
2275  int win7_crash;
2276  } invalid_table[] =
2277  {
2278  {NULL, FOREGROUND_BLUE, 0, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2280  {NULL, FOREGROUND_BLUE, 1, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2286  {output_handle, FOREGROUND_BLUE, 0, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2287  {output_handle, FOREGROUND_BLUE, 1, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2288  };
2289 
2290  for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++)
2291  {
2292  if (invalid_table[i].win7_crash)
2293  continue;
2294 
2295  SetLastError(0xdeadbeef);
2296  if (invalid_table[i].lpNumAttrsWritten) count = 0xdeadbeef;
2297  ret = FillConsoleOutputAttribute(invalid_table[i].hConsoleOutput,
2298  invalid_table[i].attr,
2299  invalid_table[i].length,
2300  invalid_table[i].coord,
2301  invalid_table[i].lpNumAttrsWritten);
2302  ok(!ret, "[%d] Expected FillConsoleOutputAttribute to return FALSE, got %d\n", i, ret);
2303  ok(GetLastError() == invalid_table[i].last_error,
2304  "[%d] Expected last error to be %u, got %u\n",
2305  i, invalid_table[i].last_error, GetLastError());
2306  }
2307 
2308  count = 0xdeadbeef;
2309  ret = FillConsoleOutputAttribute(output_handle, FOREGROUND_BLUE, 0, origin, &count);
2310  ok(ret == TRUE, "Expected FillConsoleOutputAttribute to return TRUE, got %d\n", ret);
2311  ok(count == 0, "Expected count to be 0, got %u\n", count);
2312 
2313  count = 0xdeadbeef;
2314  ret = FillConsoleOutputAttribute(output_handle, FOREGROUND_BLUE, 1, origin, &count);
2315  ok(ret == TRUE, "Expected FillConsoleOutputAttribute to return TRUE, got %d\n", ret);
2316  ok(count == 1, "Expected count to be 1, got %u\n", count);
2317 
2318  count = 0xdeadbeef;
2319  ret = FillConsoleOutputAttribute(output_handle, ~0, 1, origin, &count);
2320  ok(ret == TRUE, "Expected FillConsoleOutputAttribute to return TRUE, got %d\n", ret);
2321  ok(count == 1, "Expected count to be 1, got %u\n", count);
2322 }
#define TRUE
Definition: types.h:120
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:474
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
voidpf uLong int origin
Definition: ioapi.h:142
GLuint coord
Definition: glext.h:9511
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
Definition: cookie.c:170
int ret
__u8 attr
Definition: mkdosfs.c:359
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
Definition: bl.h:1338
#define ok(value,...)
Definition: atltest.h:57
uint32_t * LPDWORD
Definition: typedefs.h:57
#define FOREGROUND_BLUE
Definition: wincon.h:39

Referenced by START_TEST().

◆ test_FillConsoleOutputCharacterA()

static void test_FillConsoleOutputCharacterA ( HANDLE  output_handle)
static

Definition at line 2142 of file console.c.

2143 {
2144  COORD origin = {0, 0};
2145  DWORD count;
2146  BOOL ret;
2147  int i;
2148 
2149  const struct
2150  {
2151  HANDLE hConsoleOutput;
2152  CHAR ch;
2153  DWORD length;
2154  COORD coord;
2155  LPDWORD lpNumCharsWritten;
2156  DWORD last_error;
2157  int win7_crash;
2158  } invalid_table[] =
2159  {
2160  {NULL, 'a', 0, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2161  {NULL, 'a', 0, {0, 0}, &count, ERROR_INVALID_HANDLE},
2162  {NULL, 'a', 1, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2163  {NULL, 'a', 1, {0, 0}, &count, ERROR_INVALID_HANDLE},
2164  {INVALID_HANDLE_VALUE, 'a', 0, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2165  {INVALID_HANDLE_VALUE, 'a', 0, {0, 0}, &count, ERROR_INVALID_HANDLE},
2166  {INVALID_HANDLE_VALUE, 'a', 1, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2167  {INVALID_HANDLE_VALUE, 'a', 1, {0, 0}, &count, ERROR_INVALID_HANDLE},
2168  {output_handle, 'a', 0, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2169  {output_handle, 'a', 1, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2170  };
2171 
2172  for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++)
2173  {
2174  if (invalid_table[i].win7_crash)
2175  continue;
2176 
2177  SetLastError(0xdeadbeef);
2178  if (invalid_table[i].lpNumCharsWritten) count = 0xdeadbeef;
2179  ret = FillConsoleOutputCharacterA(invalid_table[i].hConsoleOutput,
2180  invalid_table[i].ch,
2181  invalid_table[i].length,
2182  invalid_table[i].coord,
2183  invalid_table[i].lpNumCharsWritten);
2184  ok(!ret, "[%d] Expected FillConsoleOutputCharacterA to return FALSE, got %d\n", i, ret);
2185  ok(GetLastError() == invalid_table[i].last_error,
2186  "[%d] Expected last error to be %u, got %u\n",
2187  i, invalid_table[i].last_error, GetLastError());
2188  }
2189 
2190  count = 0xdeadbeef;
2191  ret = FillConsoleOutputCharacterA(output_handle, 'a', 0, origin, &count);
2192  ok(ret == TRUE, "Expected FillConsoleOutputCharacterA to return TRUE, got %d\n", ret);
2193  ok(count == 0, "Expected count to be 0, got %u\n", count);
2194 
2195  count = 0xdeadbeef;
2196  ret = FillConsoleOutputCharacterA(output_handle, 'a', 1, origin, &count);
2197  ok(ret == TRUE, "Expected FillConsoleOutputCharacterA to return TRUE, got %d\n", ret);
2198  ok(count == 1, "Expected count to be 1, got %u\n", count);
2199 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
char CHAR
Definition: xmlstorage.h:175
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
voidpf uLong int origin
Definition: ioapi.h:142
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:509
GLuint coord
Definition: glext.h:9511
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
Definition: bl.h:1338
#define ok(value,...)
Definition: atltest.h:57
uint32_t * LPDWORD
Definition: typedefs.h:57

Referenced by START_TEST().

◆ test_FillConsoleOutputCharacterW()

static void test_FillConsoleOutputCharacterW ( HANDLE  output_handle)
static

Definition at line 2201 of file console.c.

2202 {
2203  COORD origin = {0, 0};
2204  DWORD count;
2205  BOOL ret;
2206  int i;
2207 
2208  const struct
2209  {
2210  HANDLE hConsoleOutput;
2211  WCHAR ch;
2212  DWORD length;
2213  COORD coord;
2214  LPDWORD lpNumCharsWritten;
2215  DWORD last_error;
2216  int win7_crash;
2217  } invalid_table[] =
2218  {
2219  {NULL, 'a', 0, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2220  {NULL, 'a', 0, {0, 0}, &count, ERROR_INVALID_HANDLE},
2221  {NULL, 'a', 1, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2222  {NULL, 'a', 1, {0, 0}, &count, ERROR_INVALID_HANDLE},
2223  {INVALID_HANDLE_VALUE, 'a', 0, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2224  {INVALID_HANDLE_VALUE, 'a', 0, {0, 0}, &count, ERROR_INVALID_HANDLE},
2225  {INVALID_HANDLE_VALUE, 'a', 1, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2226  {INVALID_HANDLE_VALUE, 'a', 1, {0, 0}, &count, ERROR_INVALID_HANDLE},
2227  {output_handle, 'a', 0, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2228  {output_handle, 'a', 1, {0, 0}, NULL, ERROR_INVALID_ACCESS, 1},
2229  };
2230 
2231  for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++)
2232  {
2233  if (invalid_table[i].win7_crash)
2234  continue;
2235 
2236  SetLastError(0xdeadbeef);
2237  if (invalid_table[i].lpNumCharsWritten) count = 0xdeadbeef;
2238  ret = FillConsoleOutputCharacterW(invalid_table[i].hConsoleOutput,
2239  invalid_table[i].ch,
2240  invalid_table[i].length,
2241  invalid_table[i].coord,
2242  invalid_table[i].lpNumCharsWritten);
2243  ok(!ret, "[%d] Expected FillConsoleOutputCharacterW to return FALSE, got %d\n", i, ret);
2244  ok(GetLastError() == invalid_table[i].last_error,
2245  "[%d] Expected last error to be %u, got %u\n",
2246  i, invalid_table[i].last_error, GetLastError());
2247  }
2248 
2249  count = 0xdeadbeef;
2250  ret = FillConsoleOutputCharacterW(output_handle, 'a', 0, origin, &count);
2251  ok(ret == TRUE, "Expected FillConsoleOutputCharacterW to return TRUE, got %d\n", ret);
2252  ok(count == 0, "Expected count to be 0, got %u\n", count);
2253 
2254  count = 0xdeadbeef;
2255  ret = FillConsoleOutputCharacterW(output_handle, 'a', 1, origin, &count);
2256  ok(ret == TRUE, "Expected FillConsoleOutputCharacterW to return TRUE, got %d\n", ret);
2257  ok(count == 1, "Expected count to be 1, got %u\n", count);
2258 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
voidpf uLong int origin
Definition: ioapi.h:142
GLuint coord
Definition: glext.h:9511
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
Definition: bl.h:1338
#define ok(value,...)
Definition: atltest.h:57
uint32_t * LPDWORD
Definition: typedefs.h:57
BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputCharacterW(IN HANDLE hConsoleOutput, IN WCHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: readwrite.c:1676

Referenced by START_TEST().

◆ test_GetConsoleFontInfo()

static void test_GetConsoleFontInfo ( HANDLE  std_output)
static

Definition at line 2814 of file console.c.

2815 {
2816  HANDLE hmod;
2817  BOOL (WINAPI *pGetConsoleFontInfo)(HANDLE, BOOL, DWORD, CONSOLE_FONT_INFO *);
2818  DWORD (WINAPI *pGetNumberOfConsoleFonts)(void);
2819  DWORD num_fonts, index, i;
2820  int memsize, win_width, win_height, tmp_w, tmp_h;
2821  CONSOLE_FONT_INFO *cfi;
2822  BOOL ret;
2824  COORD orig_sb_size, tmp_sb_size, orig_font, tmp_font;
2825 
2826  hmod = GetModuleHandleA("kernel32.dll");
2827  pGetConsoleFontInfo = (void *)GetProcAddress(hmod, "GetConsoleFontInfo");
2828  if (!pGetConsoleFontInfo)
2829  {
2830  win_skip("GetConsoleFontInfo is not available\n");
2831  return;
2832  }
2833 
2834  pGetNumberOfConsoleFonts = (void *)GetProcAddress(hmod, "GetNumberOfConsoleFonts");
2835  if (!pGetNumberOfConsoleFonts)
2836  {
2837  win_skip("GetNumberOfConsoleFonts is not available\n");
2838  return;
2839  }
2840 
2841  num_fonts = pGetNumberOfConsoleFonts();
2842  memsize = num_fonts * sizeof(CONSOLE_FONT_INFO);
2843  cfi = HeapAlloc(GetProcessHeap(), 0, memsize);
2844  memset(cfi, 0, memsize);
2845 
2846  GetConsoleScreenBufferInfo(std_output, &csbi);
2847  orig_sb_size = csbi.dwSize;
2848  tmp_sb_size.X = csbi.dwSize.X + 3;
2849  tmp_sb_size.Y = csbi.dwSize.Y + 5;
2850  SetConsoleScreenBufferSize(std_output, tmp_sb_size);
2851 
2852  SetLastError(0xdeadbeef);
2853  ret = pGetConsoleFontInfo(NULL, FALSE, 0, cfi);
2854  ok(!ret, "got %d, expected zero\n", ret);
2855  todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2856 
2857  SetLastError(0xdeadbeef);
2858  ret = pGetConsoleFontInfo(GetStdHandle(STD_INPUT_HANDLE), FALSE, 0, cfi);
2859  ok(!ret, "got %d, expected zero\n", ret);
2860  todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2861 
2862  SetLastError(0xdeadbeef);
2863  ret = pGetConsoleFontInfo(std_output, FALSE, 0, cfi);
2864  ok(!ret, "got %d, expected zero\n", ret);
2865  todo_wine ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
2866 
2867  GetConsoleScreenBufferInfo(std_output, &csbi);
2868  win_width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
2869  win_height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
2870 
2871  GetCurrentConsoleFont(std_output, FALSE, &cfi[0]);
2872  index = cfi[0].nFont;
2873  orig_font = GetConsoleFontSize(std_output, index);
2874 
2875  memset(cfi, 0, memsize);
2876  ret = pGetConsoleFontInfo(std_output, FALSE, num_fonts, cfi);
2877  todo_wine ok(ret, "got %d, expected non-zero\n", ret);
2878 
2879  todo_wine ok(cfi[index].dwFontSize.X == win_width, "got %d, expected %d\n",
2880  cfi[index].dwFontSize.X, win_width);
2881  todo_wine ok(cfi[index].dwFontSize.Y == win_height, "got %d, expected %d\n",
2882  cfi[index].dwFontSize.Y, win_height);
2883 
2884  for (i = 0; i < num_fonts; i++)
2885  {
2886  ok(cfi[i].nFont == i, "element out of order, got nFont %d, expected %d\n", cfi[i].nFont, i);
2887  tmp_font = GetConsoleFontSize(std_output, cfi[i].nFont);
2888  tmp_w = (double)orig_font.X / tmp_font.X * win_width;
2889  tmp_h = (double)orig_font.Y / tmp_font.Y * win_height;
2890  todo_wine ok(cfi[i].dwFontSize.X == tmp_w, "got %d, expected %d\n", cfi[i].dwFontSize.X, tmp_w);
2891  todo_wine ok(cfi[i].dwFontSize.Y == tmp_h, "got %d, expected %d\n", cfi[i].dwFontSize.Y, tmp_h);
2892  }
2893 
2894  SetLastError(0xdeadbeef);
2895  ret = pGetConsoleFontInfo(NULL, TRUE, 0, cfi);
2896  ok(!ret, "got %d, expected zero\n", ret);
2897  todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2898 
2899  SetLastError(0xdeadbeef);
2900  ret = pGetConsoleFontInfo(GetStdHandle(STD_INPUT_HANDLE), TRUE, 0, cfi);
2901  ok(!ret, "got %d, expected zero\n", ret);
2902  todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2903 
2904  SetLastError(0xdeadbeef);
2905  ret = pGetConsoleFontInfo(std_output, TRUE, 0, cfi);
2906  ok(!ret, "got %d, expected zero\n", ret);
2907  todo_wine ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
2908 
2909  memset(cfi, 0, memsize);
2910  ret = pGetConsoleFontInfo(std_output, TRUE, num_fonts, cfi);
2911  todo_wine ok(ret, "got %d, expected non-zero\n", ret);
2912 
2913  todo_wine ok(cfi[index].dwFontSize.X == csbi.dwMaximumWindowSize.X, "got %d, expected %d\n",
2914  cfi[index].dwFontSize.X, csbi.dwMaximumWindowSize.X);
2915  todo_wine ok(cfi[index].dwFontSize.Y == csbi.dwMaximumWindowSize.Y, "got %d, expected %d\n",
2916  cfi[index].dwFontSize.Y, csbi.dwMaximumWindowSize.Y);
2917 
2918  for (i = 0; i < num_fonts; i++)
2919  {
2920  ok(cfi[i].nFont == i, "element out of order, got nFont %d, expected %d\n", cfi[i].nFont, i);
2921  tmp_font = GetConsoleFontSize(std_output, cfi[i].nFont);
2922  tmp_w = (double)orig_font.X / tmp_font.X * csbi.dwMaximumWindowSize.X;
2923  tmp_h = (double)orig_font.Y / tmp_font.Y * csbi.dwMaximumWindowSize.Y;
2924  todo_wine ok(cfi[i].dwFontSize.X == tmp_w, "got %d, expected %d\n", cfi[i].dwFontSize.X, tmp_w);
2925  todo_wine ok(cfi[i].dwFontSize.Y == tmp_h, "got %d, expected %d\n", cfi[i].dwFontSize.Y, tmp_h);
2926  }
2927 
2928  HeapFree(GetProcessHeap(), 0, cfi);
2929  SetConsoleScreenBufferSize(std_output, orig_sb_size);
2930 }
static BOOL
Definition: console.c:28
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
static HANDLE(WINAPI *pOpenConsoleW)(LPCWSTR
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize)
Definition: console.c:1857
BOOL WINAPI GetCurrentConsoleFont(IN HANDLE hConsoleOutput, IN BOOL bMaximumWindow, OUT PCONSOLE_FONT_INFO lpConsoleCurrentFont)
Definition: console.c:694
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define STD_INPUT_HANDLE
Definition: winbase.h:264
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
#define GetProcessHeap()
Definition: compat.h:403
static DWORD
Definition: console.c:27
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
SHORT Bottom
Definition: blue.h:28
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
SHORT Top
Definition: blue.h:26
struct _CONSOLE_FONT_INFO CONSOLE_FONT_INFO
int ret
#define index(s, c)
Definition: various.h:29
#define todo_wine
Definition: test.h:154
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
Definition: bl.h:1338
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define ok(value,...)
Definition: atltest.h:57
#define GetProcAddress(x, y)
Definition: compat.h:418
SHORT Right
Definition: blue.h:27
ULONG Y
Definition: bl.h:1341
#define memset(x, y, z)
Definition: compat.h:39
COORD WINAPI DECLSPEC_HOTPATCH GetConsoleFontSize(IN HANDLE hConsoleOutput, IN DWORD nFont)
Definition: console.c:613
#define win_skip
Definition: test.h:141
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by START_TEST().

◆ test_GetConsoleFontSize()

static void test_GetConsoleFontSize ( HANDLE  std_output)
static

Definition at line 2688 of file console.c.

2689 {
2690  COORD c;
2691  DWORD index = 0;
2692  CONSOLE_FONT_INFO cfi;
2693  RECT r;
2695  LONG font_width, font_height;
2696  HMODULE hmod;
2697  DWORD (WINAPI *pGetNumberOfConsoleFonts)(void);
2698 
2699  memset(&c, 10, sizeof(COORD));
2700  SetLastError(0xdeadbeef);
2702  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2703  ok(!c.X, "got %d, expected 0\n", c.X);
2704  ok(!c.Y, "got %d, expected 0\n", c.Y);
2705 
2706  memset(&c, 10, sizeof(COORD));
2707  SetLastError(0xdeadbeef);
2709  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2710  ok(!c.X, "got %d, expected 0\n", c.X);
2711  ok(!c.Y, "got %d, expected 0\n", c.Y);
2712 
2713  GetCurrentConsoleFont(std_output, FALSE, &cfi);
2714  memset(&c, 10, sizeof(COORD));
2715  SetLastError(0xdeadbeef);
2716  c = GetConsoleFontSize(std_output, cfi.nFont);
2717  ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
2719  GetConsoleScreenBufferInfo(std_output, &csbi);
2720  font_width = (r.right - r.left + 1) / csbi.srWindow.Right;
2721  font_height = (r.bottom - r.top + 1) / csbi.srWindow.Bottom;
2722  ok(c.X == font_width, "got %d, expected %d\n", c.X, font_width);
2723  ok(c.Y == font_height, "got %d, expected %d\n", c.Y, font_height);
2724 
2725  hmod = GetModuleHandleA("kernel32.dll");
2726  pGetNumberOfConsoleFonts = (void *)GetProcAddress(hmod, "GetNumberOfConsoleFonts");
2727  if (!pGetNumberOfConsoleFonts)
2728  {
2729  win_skip("GetNumberOfConsoleFonts is not available\n");
2730  return;
2731  }
2732  index = pGetNumberOfConsoleFonts();
2733 
2734  memset(&c, 10, sizeof(COORD));
2735  SetLastError(0xdeadbeef);
2736  c = GetConsoleFontSize(std_output, index);
2737  ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
2738  ok(!c.X, "got %d, expected 0\n", c.X);
2739  ok(!c.Y, "got %d, expected 0\n", c.Y);
2740 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
BOOL WINAPI GetCurrentConsoleFont(IN HANDLE hConsoleOutput, IN BOOL bMaximumWindow, OUT PCONSOLE_FONT_INFO lpConsoleCurrentFont)
Definition: console.c:694
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define STD_INPUT_HANDLE
Definition: winbase.h:264
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
static DWORD
Definition: console.c:27
SHORT Bottom
Definition: blue.h:28
#define WINAPI
Definition: msvc.h:8
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
static int font_height(HFONT hFont)
Definition: combo.c:612
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
Definition: bl.h:1338
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define ok(value,...)
Definition: atltest.h:57
#define c
Definition: ke_i.h:80
#define GetProcAddress(x, y)
Definition: compat.h:418
SHORT Right
Definition: blue.h:27
#define memset(x, y, z)
Definition: compat.h:39
COORD WINAPI DECLSPEC_HOTPATCH GetConsoleFontSize(IN HANDLE hConsoleOutput, IN DWORD nFont)
Definition: console.c:613
#define win_skip
Definition: test.h:141
HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow(VOID)
Definition: console.c:2730

Referenced by START_TEST().

◆ test_GetConsoleProcessList()

static void test_GetConsoleProcessList ( void  )
static

Definition at line 1009 of file console.c.

1010 {
1011  DWORD ret, *list = NULL;
1012 
1013  if (!pGetConsoleProcessList)
1014  {
1015  win_skip("GetConsoleProcessList is not available\n");
1016  return;
1017  }
1018 
1019  SetLastError(0xdeadbeef);
1020  ret = pGetConsoleProcessList(NULL, 0);
1021  ok(ret == 0, "Expected failure\n");
1023  "Expected ERROR_INVALID_PARAMETER, got %d\n",
1024  GetLastError());
1025 
1026  SetLastError(0xdeadbeef);
1027  ret = pGetConsoleProcessList(NULL, 1);
1028  ok(ret == 0, "Expected failure\n");
1030  "Expected ERROR_INVALID_PARAMETER, got %d\n",
1031  GetLastError());
1032 
1033  /* We should only have 1 process but only for these specific unit tests as
1034  * we created our own console. An AttachConsole(ATTACH_PARENT_PROCESS) would
1035  * give us two processes for example.
1036  */
1037  list = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
1038 
1039  SetLastError(0xdeadbeef);
1040  ret = pGetConsoleProcessList(list, 0);
1041  ok(ret == 0, "Expected failure\n");
1043  "Expected ERROR_INVALID_PARAMETER, got %d\n",
1044  GetLastError());
1045 
1046  SetLastError(0xdeadbeef);
1047  ret = pGetConsoleProcessList(list, 1);
1048  todo_wine
1049  ok(ret == 1, "Expected 1, got %d\n", ret);
1050 
1051  HeapFree(GetProcessHeap(), 0, list);
1052 
1053  list = HeapAlloc(GetProcessHeap(), 0, ret * sizeof(DWORD));
1054 
1055  SetLastError(0xdeadbeef);
1056  ret = pGetConsoleProcessList(list, ret);
1057  todo_wine
1058  ok(ret == 1, "Expected 1, got %d\n", ret);
1059 
1060  if (ret == 1)
1061  {
1063  ok(list[0] == pid, "Expected %d, got %d\n", pid, list[0]);
1064  }
1065 
1066  HeapFree(GetProcessHeap(), 0, list);
1067 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define todo_wine
Definition: test.h:154
Definition: _list.h:228
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:141
#define HeapFree(x, y, z)
Definition: compat.h:402
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158

Referenced by START_TEST().

◆ test_GetConsoleScreenBufferInfoEx()

static void test_GetConsoleScreenBufferInfoEx ( HANDLE  std_output)
static

Definition at line 2973 of file console.c.

2974 {
2975  HANDLE hmod;
2976  BOOL (WINAPI *pGetConsoleScreenBufferInfoEx)(HANDLE, CONSOLE_SCREEN_BUFFER_INFOEX *);
2977  CONSOLE_SCREEN_BUFFER_INFOEX csbix;
2978  BOOL ret;
2979  HANDLE std_input = GetStdHandle(STD_INPUT_HANDLE);
2980 
2981  hmod = GetModuleHandleA("kernel32.dll");
2982  pGetConsoleScreenBufferInfoEx = (void *)GetProcAddress(hmod, "GetConsoleScreenBufferInfoEx");
2983  if (!pGetConsoleScreenBufferInfoEx)
2984  {
2985  win_skip("GetConsoleScreenBufferInfoEx is not available\n");
2986  return;
2987  }
2988 
2989  SetLastError(0xdeadbeef);
2990  ret = pGetConsoleScreenBufferInfoEx(NULL, &csbix);
2991  ok(!ret, "got %d, expected zero\n", ret);
2992  ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
2993 
2994  SetLastError(0xdeadbeef);
2995  ret = pGetConsoleScreenBufferInfoEx(std_input, &csbix);
2996  ok(!ret, "got %d, expected zero\n", ret);
2997  ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
2998 
2999  SetLastError(0xdeadbeef);
3000  ret = pGetConsoleScreenBufferInfoEx(std_output, &csbix);
3001  ok(!ret, "got %d, expected zero\n", ret);
3002  ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
3003 
3004  csbix.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
3005 
3006  SetLastError(0xdeadbeef);
3007  ret = pGetConsoleScreenBufferInfoEx(NULL, &csbix);
3008  ok(!ret, "got %d, expected zero\n", ret);
3009  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
3010 
3011  SetLastError(0xdeadbeef);
3012  ret = pGetConsoleScreenBufferInfoEx(std_input, &csbix);
3013  ok(!ret, "got %d, expected zero\n", ret);
3014  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
3015 
3016  SetLastError(0xdeadbeef);
3017  ret = pGetConsoleScreenBufferInfoEx(std_output, &csbix);
3018  ok(ret, "got %d, expected non-zero\n", ret);
3019  ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
3020 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static BOOL
Definition: console.c:28
static HANDLE(WINAPI *pOpenConsoleW)(LPCWSTR
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define STD_INPUT_HANDLE
Definition: winbase.h:264
#define WINAPI
Definition: msvc.h:8
#define SetLastError(x)
Definition: compat.h:417
int ret
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define ok(value,...)
Definition: atltest.h:57
#define GetProcAddress(x, y)
Definition: compat.h:418
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_GetCurrentConsoleFont()

static void test_GetCurrentConsoleFont ( HANDLE  std_output)
static

Definition at line 2623 of file console.c.

2624 {
2625  BOOL ret;
2626  CONSOLE_FONT_INFO cfi;
2628  short int width, height;
2629  COORD c;
2630 
2631  memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
2632  SetLastError(0xdeadbeef);
2633  ret = GetCurrentConsoleFont(NULL, FALSE, &cfi);
2634  ok(!ret, "got %d, expected 0\n", ret);
2635  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2636  ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
2637  ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
2638 
2639  memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
2640  SetLastError(0xdeadbeef);
2641  ret = GetCurrentConsoleFont(NULL, TRUE, &cfi);
2642  ok(!ret, "got %d, expected 0\n", ret);
2643  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2644  ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
2645  ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
2646 
2647  memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
2648  SetLastError(0xdeadbeef);
2650  ok(!ret, "got %d, expected 0\n", ret);
2651  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2652  ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
2653  ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
2654 
2655  memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
2656  SetLastError(0xdeadbeef);
2658  ok(!ret, "got %d, expected 0\n", ret);
2659  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2660  ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
2661  ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
2662 
2663  memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
2664  SetLastError(0xdeadbeef);
2665  ret = GetCurrentConsoleFont(std_output, FALSE, &cfi);
2666  ok(ret, "got %d, expected non-zero\n", ret);
2667  ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
2668  GetConsoleScreenBufferInfo(std_output, &csbi);
2669  width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
2670  height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
2671  c = GetConsoleFontSize(std_output, cfi.nFont);
2672  ok(cfi.dwFontSize.X == width || cfi.dwFontSize.X == c.X /* Vista and higher */,
2673  "got %d, expected %d\n", cfi.dwFontSize.X, width);
2674  ok(cfi.dwFontSize.Y == height || cfi.dwFontSize.Y == c.Y /* Vista and higher */,
2675  "got %d, expected %d\n", cfi.dwFontSize.Y, height);
2676 
2677  memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
2678  SetLastError(0xdeadbeef);
2679  ret = GetCurrentConsoleFont(std_output, TRUE, &cfi);
2680  ok(ret, "got %d, expected non-zero\n", ret);
2681  ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
2682  ok(cfi.dwFontSize.X == csbi.dwMaximumWindowSize.X,
2683  "got %d, expected %d\n", cfi.dwFontSize.X, csbi.dwMaximumWindowSize.X);
2684  ok(cfi.dwFontSize.Y == csbi.dwMaximumWindowSize.Y,
2685  "got %d, expected %d\n", cfi.dwFontSize.Y, csbi.dwMaximumWindowSize.Y);
2686 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
COORD dwFontSize
Definition: wincon.h:200
BOOL WINAPI GetCurrentConsoleFont(IN HANDLE hConsoleOutput, IN BOOL bMaximumWindow, OUT PCONSOLE_FONT_INFO lpConsoleCurrentFont)
Definition: console.c:694
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define STD_INPUT_HANDLE
Definition: winbase.h:264
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:28
const GLubyte * c
Definition: glext.h:8905
#define SetLastError(x)
Definition: compat.h:417
SHORT Top
Definition: blue.h:26
int ret
Definition: bl.h:1338
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ok(value,...)
Definition: atltest.h:57
#define c
Definition: ke_i.h:80
SHORT Right
Definition: blue.h:27
ULONG Y
Definition: bl.h:1341
#define memset(x, y, z)
Definition: compat.h:39
COORD WINAPI DECLSPEC_HOTPATCH GetConsoleFontSize(IN HANDLE hConsoleOutput, IN DWORD nFont)
Definition: console.c:613

Referenced by START_TEST().

◆ test_GetLargestConsoleWindowSize()

static void test_GetLargestConsoleWindowSize ( HANDLE  std_output)
static

Definition at line 2742 of file console.c.

2743 {
2744  COORD c, font;
2745  RECT r;
2746  LONG workarea_w, workarea_h, maxcon_w, maxcon_h;
2748  CONSOLE_FONT_INFO cfi;
2749  DWORD index, i;
2750  HMODULE hmod;
2751  BOOL ret;
2752  DWORD (WINAPI *pGetNumberOfConsoleFonts)(void);
2753  BOOL (WINAPI *pSetConsoleFont)(HANDLE, DWORD);
2754 
2755  memset(&c, 10, sizeof(COORD));
2756  SetLastError(0xdeadbeef);
2758  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2759  ok(!c.X, "got %d, expected 0\n", c.X);
2760  ok(!c.Y, "got %d, expected 0\n", c.Y);
2761 
2762  memset(&c, 10, sizeof(COORD));
2763  SetLastError(0xdeadbeef);
2765  ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2766  ok(!c.X, "got %d, expected 0\n", c.X);
2767  ok(!c.Y, "got %d, expected 0\n", c.Y);
2768 
2769  SystemParametersInfoW(SPI_GETWORKAREA, 0, &r, 0);
2770  workarea_w = r.right - r.left;
2771  workarea_h = r.bottom - r.top - GetSystemMetrics(SM_CYCAPTION);
2772 
2773  GetCurrentConsoleFont(std_output, FALSE, &cfi);
2774  index = cfi.nFont; /* save current font index */
2775 
2776  hmod = GetModuleHandleA("kernel32.dll");
2777  pGetNumberOfConsoleFonts = (void *)GetProcAddress(hmod, "GetNumberOfConsoleFonts");
2778  if (!pGetNumberOfConsoleFonts)
2779  {
2780  win_skip("GetNumberOfConsoleFonts is not available\n");
2781  return;
2782  }
2783  pSetConsoleFont = (void *)GetProcAddress(hmod, "SetConsoleFont");
2784  if (!pSetConsoleFont)
2785  {
2786  win_skip("SetConsoleFont is not available\n");
2787  return;
2788  }
2789 
2790  for (i = 0; i < pGetNumberOfConsoleFonts(); i++)
2791  {
2792  pSetConsoleFont(std_output, i);
2793  memset(&c, 10, sizeof(COORD));
2794  SetLastError(0xdeadbeef);
2795  c = GetLargestConsoleWindowSize(std_output);
2796  ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
2797  GetCurrentConsoleFont(std_output, FALSE, &cfi);
2798  font = GetConsoleFontSize(std_output, cfi.nFont);
2799  maxcon_w = workarea_w / font.X;
2800  maxcon_h = workarea_h / font.Y;
2801  ok(c.X == maxcon_w || c.X == maxcon_w - 1 /* Win10 */, "got %d, expected %d\n", c.X, maxcon_w);
2802  ok(c.Y == maxcon_h || c.Y == maxcon_h - 1 /* Win10 */, "got %d, expected %d\n", c.Y, maxcon_h);
2803 
2804  ret = GetConsoleScreenBufferInfo(std_output, &sbi);
2805  ok(ret, "GetConsoleScreenBufferInfo failed %u\n", GetLastError());
2806  ok(sbi.dwMaximumWindowSize.X == min(c.X, sbi.dwSize.X), "got %d, expected %d\n",
2807  sbi.dwMaximumWindowSize.X, min(c.X, sbi.dwSize.X));
2808  ok(sbi.dwMaximumWindowSize.Y == min(c.Y, sbi.dwSize.Y), "got %d, expected %d\n",
2809  sbi.dwMaximumWindowSize.Y, min(c.Y, sbi.dwSize.Y));
2810  }
2811  pSetConsoleFont(std_output, index); /* restore original font size */
2812 }
static BOOL
Definition: console.c:28
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
static HANDLE(WINAPI *pOpenConsoleW)(LPCWSTR
Definition: mk_font.cpp:20
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
BOOL WINAPI GetCurrentConsoleFont(IN HANDLE hConsoleOutput, IN BOOL bMaximumWindow, OUT PCONSOLE_FONT_INFO lpConsoleCurrentFont)
Definition: console.c:694
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define STD_INPUT_HANDLE
Definition: winbase.h:264
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
ULONG X
Definition: bl.h:1340
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
static DWORD
Definition: console.c:27
#define SM_CYCAPTION
Definition: winuser.h:953
#define WINAPI
Definition: msvc.h:8
const GLubyte * c
Definition: glext.h:8905
int WINAPI GetSystemMetrics(_In_ int)
COORD WINAPI DECLSPEC_HOTPATCH GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
Definition: console.c:1675
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define index(s, c)
Definition: various.h:29
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
Definition: bl.h:1338
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
#define c
Definition: ke_i.h:80
#define GetProcAddress(x, y)
Definition: compat.h:418
ULONG Y
Definition: bl.h:1341
#define memset(x, y, z)
Definition: compat.h:39
COORD WINAPI DECLSPEC_HOTPATCH GetConsoleFontSize(IN HANDLE hConsoleOutput, IN DWORD nFont)
Definition: console.c:613
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_GetNumberOfConsoleInputEvents()

static void test_GetNumberOfConsoleInputEvents ( HANDLE  input_handle)
static

Definition at line 1364 of file console.c.

1365 {
1366  DWORD count;
1367  BOOL ret;
1368  int i;
1369 
1370  const struct
1371  {
1372  HANDLE handle;
1373  LPDWORD nrofevents;
1374  DWORD last_error;
1375  } invalid_table[] =
1376  {
1381  };
1382 
1383  for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++)
1384  {
1385  SetLastError(0xdeadbeef);
1386  if (invalid_table[i].nrofevents) count = 0xdeadbeef;
1387  ret = GetNumberOfConsoleInputEvents(invalid_table[i].handle,
1388  invalid_table[i].nrofevents);
1389  ok(!ret, "[%d] Expected GetNumberOfConsoleInputEvents to return FALSE, got %d\n", i, ret);
1390  if (invalid_table[i].nrofevents)
1391  {
1392  ok(count == 0xdeadbeef,
1393  "[%d] Expected output count to be unmodified, got %u\n", i, count);
1394  }
1395  ok(GetLastError() == invalid_table[i].last_error,
1396  "[%d] Expected last error to be %u, got %u\n",
1397  i, invalid_table[i].last_error, GetLastError());
1398  }
1399 
1400  /* Test crashes on Windows 7. */
1401  if (0)
1402  {
1403  SetLastError(0xdeadbeef);
1404  ret = GetNumberOfConsoleInputEvents(input_handle, NULL);
1405  ok(!ret, "Expected GetNumberOfConsoleInputEvents to return FALSE, got %d\n", ret);
1407  "Expected last error to be ERROR_INVALID_ACCESS, got %u\n",
1408  GetLastError());
1409  }
1410 
1411  count = 0xdeadbeef;
1412  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1413  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1414  ok(count != 0xdeadbeef, "Expected output count to initialized\n");
1415 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE hConsoleInput, LPDWORD lpNumberOfEvents)
Definition: console.c:1637
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
#define ok(value,...)
Definition: atltest.h:57
uint32_t * LPDWORD
Definition: typedefs.h:57

Referenced by START_TEST().

◆ test_GetSetConsoleInputExeName()

static void test_GetSetConsoleInputExeName ( void  )
static

Definition at line 963 of file console.c.

964 {
965  BOOL ret;
966  DWORD error;
967  char buffer[MAX_PATH], module[MAX_PATH], *p;
968  static char input_exe[MAX_PATH] = "winetest.exe";
969 
970  SetLastError(0xdeadbeef);
971  ret = pGetConsoleInputExeNameA(0, NULL);
972  error = GetLastError();
973  ok(ret, "GetConsoleInputExeNameA failed\n");
974  ok(error == ERROR_BUFFER_OVERFLOW, "got %u expected ERROR_BUFFER_OVERFLOW\n", error);
975 
976  SetLastError(0xdeadbeef);
977  ret = pGetConsoleInputExeNameA(0, buffer);
978  error = GetLastError();
979  ok(ret, "GetConsoleInputExeNameA failed\n");
980  ok(error == ERROR_BUFFER_OVERFLOW, "got %u expected ERROR_BUFFER_OVERFLOW\n", error);
981 
983  p = strrchr(module, '\\') + 1;
984 
985  ret = pGetConsoleInputExeNameA(sizeof(buffer)/sizeof(buffer[0]), buffer);
986  ok(ret, "GetConsoleInputExeNameA failed\n");
987  todo_wine ok(!lstrcmpA(buffer, p), "got %s expected %s\n", buffer, p);
988 
989  SetLastError(0xdeadbeef);
990  ret = pSetConsoleInputExeNameA(NULL);
991  error = GetLastError();
992  ok(!ret, "SetConsoleInputExeNameA failed\n");
993  ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
994 
995  SetLastError(0xdeadbeef);
996  ret = pSetConsoleInputExeNameA("");
997  error = GetLastError();
998  ok(!ret, "SetConsoleInputExeNameA failed\n");
999  ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
1000 
1001  ret = pSetConsoleInputExeNameA(input_exe);
1002  ok(ret, "SetConsoleInputExeNameA failed\n");
1003 
1004  ret = pGetConsoleInputExeNameA(sizeof(buffer)/sizeof(buffer[0]), buffer);
1005  ok(ret, "GetConsoleInputExeNameA failed\n");
1006  ok(!lstrcmpA(buffer, input_exe), "got %s expected %s\n", buffer, input_exe);
1007 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:548
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define todo_wine
Definition: test.h:154
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
#define ok(value,...)
Definition: atltest.h:57
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by START_TEST().

◆ test_GetSetStdHandle()

static void test_GetSetStdHandle ( void  )
static

Definition at line 1328 of file console.c.

1329 {
1330  HANDLE handle;
1331  DWORD error;
1332  BOOL ret;
1333 
1334  /* get invalid std handle */
1335  SetLastError(0xdeadbeef);
1336  handle = GetStdHandle(42);
1337  error = GetLastError();
1339  "wrong GetLastError() %d\n", error);
1340  ok(handle == INVALID_HANDLE_VALUE, "expected INVALID_HANDLE_VALUE\n");
1341 
1342  /* get valid */
1343  SetLastError(0xdeadbeef);
1345  error = GetLastError();
1346  ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
1347 
1348  /* set invalid std handle */
1349  SetLastError(0xdeadbeef);
1350  ret = SetStdHandle(42, handle);
1351  error = GetLastError();
1352  ok(!ret, "expected SetStdHandle to fail\n");
1354  "wrong GetLastError() %d\n", error);
1355 
1356  /* set valid (restore old value) */
1357  SetLastError(0xdeadbeef);
1359  error = GetLastError();
1360  ok(ret, "expected SetStdHandle to succeed\n");
1361  ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
1362 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
unsigned int BOOL
Definition: ntddk_ex.h:94
#define STD_INPUT_HANDLE
Definition: winbase.h:264
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandle(DWORD nStdHandle, HANDLE hHandle)
Definition: console.c:1213
int ret
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

◆ test_OpenCON()

static void test_OpenCON ( void  )
static

Definition at line 1069 of file console.c.

1070 {
1071  static const WCHAR conW[] = {'C','O','N',0};
1072  static const DWORD accesses[] = {CREATE_NEW, CREATE_ALWAYS, OPEN_EXISTING,
1074  unsigned i;
1075  HANDLE h;
1076 
1077  for (i = 0; i < sizeof(accesses) / sizeof(accesses[0]); i++)
1078  {
1079  h = CreateFileW(conW, GENERIC_WRITE, 0, NULL, accesses[i], 0, NULL);
1080  ok(h != INVALID_HANDLE_VALUE || broken(accesses[i] == TRUNCATE_EXISTING /* Win8 */),
1081  "Expected to open the CON device on write (%x)\n", accesses[i]);
1082  CloseHandle(h);
1083 
1084  h = CreateFileW(conW, GENERIC_READ, 0, NULL, accesses[i], 0, NULL);
1085  /* Windows versions differ here:
1086  * MSDN states in CreateFile that TRUNCATE_EXISTING requires GENERIC_WRITE
1087  * NT, XP, Vista comply, but Win7 doesn't and allows opening CON with TRUNCATE_EXISTING
1088  * So don't test when disposition is TRUNCATE_EXISTING
1089  */
1090  ok(h != INVALID_HANDLE_VALUE || broken(accesses[i] == TRUNCATE_EXISTING /* Win7+ */),
1091  "Expected to open the CON device on read (%x)\n", accesses[i]);
1092  CloseHandle(h);
1093  h = CreateFileW(conW, GENERIC_READ|GENERIC_WRITE, 0, NULL, accesses[i], 0, NULL);
1094  ok(h == INVALID_HANDLE_VALUE, "Expected not to open the CON device on read-write (%x)\n", accesses[i]);
1096  "Unexpected error %x\n", GetLastError());
1097  }
1098 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CloseHandle
Definition: compat.h:406
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define OPEN_EXISTING
Definition: compat.h:434
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define OPEN_ALWAYS
Definition: disk.h:70
#define GENERIC_READ
Definition: compat.h:124
#define broken(x)
Definition: _sntprintf.h:21
#define CREATE_ALWAYS
Definition: disk.h:72
#define ok(value,...)
Definition: atltest.h:57
#define CreateFileW
Definition: compat.h:408
#define CREATE_NEW
Definition: disk.h:69
#define TRUNCATE_EXISTING
Definition: disk.h:71

Referenced by START_TEST().

◆ test_OpenConsoleW()

static void test_OpenConsoleW ( void  )
static

Definition at line 1100 of file console.c.

1101 {
1102  static const WCHAR coninW[] = {'C','O','N','I','N','$',0};
1103  static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0};
1104  static const WCHAR emptyW[] = {0};
1105  static const WCHAR invalidW[] = {'I','N','V','A','L','I','D',0};
1106  DWORD gle;
1107 
1108  static const struct
1109  {
1110  LPCWSTR name;
1111  DWORD access;
1112  BOOL inherit;
1113  DWORD creation;
1114  DWORD gle, gle2;
1115  } invalid_table[] = {
1119  {NULL, 0xdeadbeef, TRUE, 0xdeadbeef, ERROR_INVALID_PARAMETER, ERROR_PATH_NOT_FOUND},
1127  {emptyW, 0xdeadbeef, TRUE, 0xdeadbeef, ERROR_INVALID_PARAMETER, ERROR_PATH_NOT_FOUND},
1133  {invalidW, 0, FALSE, 0xdeadbeef, ERROR_INVALID_PARAMETER, 0},
1135  {invalidW, 0xdeadbeef, TRUE, 0xdeadbeef, ERROR_INVALID_PARAMETER, 0},
1140  {coninW, 0, FALSE, 0xdeadbeef, ERROR_INVALID_PARAMETER, 0},
1141  {coninW, 0xdeadbeef, FALSE, 0, ERROR_INVALID_PARAMETER, ERROR_ACCESS_DENIED},
1142  {coninW, 0xdeadbeef, TRUE, 0xdeadbeef, ERROR_INVALID_PARAMETER, 0},
1143  {conoutW, 0, FALSE, 0xdeadbeef, ERROR_INVALID_PARAMETER, 0},
1144  {conoutW, 0xceadbeef, FALSE, 0, ERROR_INVALID_PARAMETER, ERROR_ACCESS_DENIED},
1145  {conoutW, 0xdeadbeef, TRUE, 0xdeadbeef, ERROR_INVALID_PARAMETER, 0},
1146  };
1147  static const struct
1148  {
1149  LPCWSTR name;
1150  DWORD access;
1151  BOOL inherit;
1152  DWORD creation;
1153  } valid_table[] = {
1154  {coninW, 0, FALSE, 0 },
1155  {coninW, 0, TRUE, 0 },
1156  {coninW, GENERIC_EXECUTE, TRUE, 0 },
1157  {coninW, GENERIC_ALL, TRUE, 0 },
1158  {coninW, 0, FALSE, OPEN_ALWAYS },
1159  {coninW, GENERIC_READ | GENERIC_WRITE, FALSE, 0 },
1160  {coninW, GENERIC_READ | GENERIC_WRITE, FALSE, CREATE_NEW },
1164  {conoutW, 0, FALSE, 0 },
1165  {conoutW, 0, FALSE, OPEN_ALWAYS },
1166  {conoutW, GENERIC_READ | GENERIC_WRITE, FALSE, 0 },
1167  {conoutW, GENERIC_READ | GENERIC_WRITE, FALSE, CREATE_NEW, },
1169  {conoutW, GENERIC_READ | GENERIC_WRITE, FALSE, OPEN_ALWAYS },
1171  };
1172 
1173  int index;
1174  HANDLE ret;
1175 
1176  if (!pOpenConsoleW)
1177  {
1178  win_skip("OpenConsoleW is not available\n");
1179  return;
1180  }
1181 
1182  for (index = 0; index < sizeof(invalid_table)/sizeof(invalid_table[0]); index++)
1183  {
1184  SetLastError(0xdeadbeef);
1185  ret = pOpenConsoleW(invalid_table[index].name, invalid_table[index].access,
1186  invalid_table[index].inherit, invalid_table[index].creation);
1187  gle = GetLastError();
1189  "Expected OpenConsoleW to return INVALID_HANDLE_VALUE for index %d, got %p\n",
1190  index, ret);
1191  ok(gle == invalid_table[index].gle || (gle != 0 && gle == invalid_table[index].gle2),
1192  "Expected GetLastError() to return %u/%u for index %d, got %u\n",
1193  invalid_table[index].gle, invalid_table[index].gle2, index, gle);
1194  }
1195 
1196  for (index = 0; index < sizeof(valid_table)/sizeof(valid_table[0]); index++)
1197  {
1198  ret = pOpenConsoleW(valid_table[index].name, valid_table[index].access,
1199  valid_table[index].inherit, valid_table[index].creation);
1200  todo_wine
1201  ok(ret != INVALID_HANDLE_VALUE || broken(ret == INVALID_HANDLE_VALUE /* until Win7 */),
1202  "Expected OpenConsoleW to succeed for index %d, got %p\n", index, ret);
1203  if (ret != INVALID_HANDLE_VALUE)
1204  CloseHandle(ret);
1205  }
1206 
1207  ret = pOpenConsoleW(coninW, GENERIC_READ | GENERIC_WRITE, FALSE, OPEN_EXISTING);
1208  ok(ret != INVALID_HANDLE_VALUE, "Expected OpenConsoleW to return a valid handle\n");
1209  if (ret != INVALID_HANDLE_VALUE)
1210  CloseHandle(ret);
1211 
1212  ret = pOpenConsoleW(conoutW, GENERIC_READ | GENERIC_WRITE, FALSE, OPEN_EXISTING);
1213  ok(ret != INVALID_HANDLE_VALUE, "Expected OpenConsoleW to return a valid handle\n");
1214  if (ret != INVALID_HANDLE_VALUE)
1215  CloseHandle(ret);
1216 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define GENERIC_ALL
Definition: nt_native.h:92
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static const WCHAR invalidW[]
Definition: locale.c:46
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define OPEN_EXISTING
Definition: compat.h:434
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#define OPEN_ALWAYS
Definition: disk.h:70
int ret
#define index(s, c)
Definition: various.h:29
#define todo_wine
Definition: test.h:154
#define GENERIC_READ
Definition: compat.h:124
#define broken(x)
Definition: _sntprintf.h:21
#define CREATE_ALWAYS
Definition: disk.h:72
static const WCHAR emptyW[]
Definition: navigate.c:40
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
#define ok(value,...)
Definition: atltest.h:57
Definition: name.c:36
#define CREATE_NEW
Definition: disk.h:69
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define TRUNCATE_EXISTING
Definition: disk.h:71
#define GENERIC_EXECUTE
Definition: nt_native.h:91
#define win_skip
Definition: test.h:141
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by START_TEST().

◆ test_ReadConsole()

static void test_ReadConsole ( void  )
static

Definition at line 2575 of file console.c.

2576 {
2577  HANDLE std_input;
2578  DWORD ret, bytes;
2579  char buf[1024];
2580 
2581  std_input = GetStdHandle(STD_INPUT_HANDLE);
2582 
2583  SetLastError(0xdeadbeef);
2584  ret = GetFileSize(std_input, NULL);
2585  if (GetLastError() == 0xdeadbeef)
2586  {
2587  skip("stdin is redirected\n");
2588  return;
2589  }
2590  ok(ret == INVALID_FILE_SIZE, "expected INVALID_FILE_SIZE, got %#x\n", ret);
2592  GetLastError() == ERROR_INVALID_FUNCTION, /* Win 8, 10 */
2593  "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
2594 
2595  bytes = 0xdeadbeef;
2596  SetLastError(0xdeadbeef);
2597  ret = ReadFile(std_input, buf, -128, &bytes, NULL);
2598  ok(!ret, "expected 0, got %u\n", ret);
2600  GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
2601  "expected ERROR_NOT_ENOUGH_MEMORY, got %d\n", GetLastError());
2602  ok(!bytes, "expected 0, got %u\n", bytes);
2603 
2604  bytes = 0xdeadbeef;
2605  SetLastError(0xdeadbeef);
2606  ret = ReadConsoleA(std_input, buf, -128, &bytes, NULL);
2607  ok(!ret, "expected 0, got %u\n", ret);
2609  GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
2610  "expected ERROR_NOT_ENOUGH_MEMORY, got %d\n", GetLastError());
2611  ok(bytes == 0xdeadbeef, "expected 0xdeadbeef, got %#x\n", bytes);
2612 
2613  bytes = 0xdeadbeef;
2614  SetLastError(0xdeadbeef);
2615  ret = ReadConsoleW(std_input, buf, -128, &bytes, NULL);
2616  ok(!ret, "expected 0, got %u\n", ret);
2618  GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
2619  "expected ERROR_NOT_ENOUGH_MEMORY, got %d\n", GetLastError());
2620  ok(bytes == 0xdeadbeef, "expected 0xdeadbeef, got %#x\n", bytes);
2621 }
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
#define INVALID_FILE_SIZE
Definition: winbase.h:529
#define ERROR_NOACCESS
Definition: winerror.h:578
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
smooth NULL
Definition: ftsmooth.c:416
#define STD_INPUT_HANDLE
Definition: winbase.h:264
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleW(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
Definition: readwrite.c:1176
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleA(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
Definition: readwrite.c:1197
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define SetLastError(x)
Definition: compat.h:417
int ret
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

Referenced by START_TEST().

◆ test_ReadConsoleOutputAttribute()

static void test_ReadConsoleOutputAttribute ( HANDLE  output_handle)
static

Definition at line 2492 of file console.c.

2493 {
2494  WORD attr;
2495  COORD origin = {0, 0};
2496  DWORD count;
2497  BOOL ret;
2498  int i;
2499 
2500  const struct
2501  {
2502  HANDLE hConsoleOutput;
2503  LPWORD lpAttribute;
2504  DWORD length;
2505  COORD coord;
2506  LPDWORD read_count;
2508  DWORD last_error;
2509  int win7_crash;
2510  } invalid_table[] =
2511  {
2512  {NULL, NULL, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2513  {NULL, NULL, 0, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2514  {NULL, NULL, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2515  {NULL, NULL, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE, 1},
2516  {NULL, &attr, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2517  {NULL, &attr, 0, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2518  {NULL, &attr, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2519  {NULL, &attr, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2520  {INVALID_HANDLE_VALUE, NULL, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2522  {INVALID_HANDLE_VALUE, NULL, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2523  {INVALID_HANDLE_VALUE, NULL, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE, 1},
2524  {INVALID_HANDLE_VALUE, &attr, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2525  {INVALID_HANDLE_VALUE, &attr, 0, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2526  {INVALID_HANDLE_VALUE, &attr, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2527  {INVALID_HANDLE_VALUE, &attr, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2528  {output_handle, NULL, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2529  {output_handle, NULL, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2530  {output_handle, NULL, 1, {0, 0}, &count, 1, ERROR_INVALID_ACCESS, 1},
2531  {output_handle, &attr, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2532  {output_handle, &attr, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2533  };
2534 
2535  for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++)
2536  {
2537  if (invalid_table[i].win7_crash)
2538  continue;
2539 
2540  SetLastError(0xdeadbeef);
2541  if (invalid_table[i].read_count) count = 0xdeadbeef;
2542  ret = ReadConsoleOutputAttribute(invalid_table[i].hConsoleOutput,
2543  invalid_table[i].lpAttribute,
2544  invalid_table[i].length,
2545  invalid_table[i].coord,
2546  invalid_table[i].read_count);
2547  ok(!ret, "[%d] Expected ReadConsoleOutputAttribute to return FALSE, got %d\n", i, ret);
2548  if (invalid_table[i].read_count)
2549  {
2550  ok(count == invalid_table[i].expected_count,
2551  "[%d] Expected count to be %u, got %u\n",
2552  i, invalid_table[i].expected_count, count);
2553  }
2554  ok(GetLastError() == invalid_table[i].last_error,
2555  "[%d] Expected last error to be %u, got %u\n",
2556  i, invalid_table[i].last_error, GetLastError());
2557  }
2558 
2559  count = 0xdeadbeef;
2560  ret = ReadConsoleOutputAttribute(output_handle, NULL, 0, origin, &count);
2561  ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret);
2562  ok(count == 0, "Expected count to be 0, got %u\n", count);
2563 
2564  count = 0xdeadbeef;
2565  ret = ReadConsoleOutputAttribute(output_handle, &attr, 0, origin, &count);
2566  ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret);
2567  ok(count == 0, "Expected count to be 0, got %u\n", count);
2568 
2569  count = 0xdeadbeef;
2570  ret = ReadConsoleOutputAttribute(output_handle, &attr, 1, origin, &count);
2571  ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret);
2572  ok(count == 1, "Expected count to be 1, got %u\n", count);
2573 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
voidpf uLong int origin
Definition: ioapi.h:142
GLuint coord
Definition: glext.h:9511
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputAttribute(IN HANDLE hConsoleOutput, OUT LPWORD lpAttribute, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfAttrsRead)
Definition: readwrite.c:1424
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
Definition: cookie.c:170
int ret
__u8 attr
Definition: mkdosfs.c:359
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
Definition: bl.h:1338
uint16_t * LPWORD
Definition: typedefs.h:54
#define ok(value,...)
Definition: atltest.h:57
static int expected_count(int *sink)
uint32_t * LPDWORD
Definition: typedefs.h:57

Referenced by START_TEST().

◆ test_ReadConsoleOutputCharacterA()

static void test_ReadConsoleOutputCharacterA ( HANDLE  output_handle)
static

Definition at line 2324 of file console.c.

2325 {
2326  CHAR read;
2327  COORD origin = {0, 0};
2328  DWORD count;
2329  BOOL ret;
2330  int i;
2331 
2332  const struct
2333  {
2334  HANDLE hConsoleOutput;
2335  LPSTR lpstr;
2336  DWORD length;
2337  COORD coord;
2338  LPDWORD read_count;
2340  DWORD last_error;
2341  int win7_crash;
2342  } invalid_table[] =
2343  {
2344  {NULL, NULL, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2345  {NULL, NULL, 0, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2346  {NULL, NULL, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2347  {NULL, NULL, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE, 1},
2348  {NULL, &read, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2349  {NULL, &read, 0, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2350  {NULL, &read, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2351  {NULL, &read, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2352  {INVALID_HANDLE_VALUE, NULL, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2354  {INVALID_HANDLE_VALUE, NULL, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2355  {INVALID_HANDLE_VALUE, NULL, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE, 1},
2356  {INVALID_HANDLE_VALUE, &read, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2357  {INVALID_HANDLE_VALUE, &read, 0, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2358  {INVALID_HANDLE_VALUE, &read, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2359  {INVALID_HANDLE_VALUE, &read, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2360  {output_handle, NULL, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2361  {output_handle, NULL, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2362  {output_handle, NULL, 1, {0, 0}, &count, 1, ERROR_INVALID_ACCESS, 1},
2363  {output_handle, NULL, 10, {0, 0}, &count, 10, ERROR_INVALID_ACCESS, 1},
2364  {output_handle, &read, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2365  {output_handle, &read, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2366  };
2367 
2368  for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++)
2369  {
2370  if (invalid_table[i].win7_crash)
2371  continue;
2372 
2373  SetLastError(0xdeadbeef);
2374  if (invalid_table[i].read_count) count = 0xdeadbeef;
2375  ret = ReadConsoleOutputCharacterA(invalid_table[i].hConsoleOutput,
2376  invalid_table[i].lpstr,
2377  invalid_table[i].length,
2378  invalid_table[i].coord,
2379  invalid_table[i].read_count);
2380  ok(!ret, "[%d] Expected ReadConsoleOutputCharacterA to return FALSE, got %d\n", i, ret);
2381  if (invalid_table[i].read_count)
2382  {
2383  ok(count == invalid_table[i].expected_count,
2384  "[%d] Expected count to be %u, got %u\n",
2385  i, invalid_table[i].expected_count, count);
2386  }
2387  ok(GetLastError() == invalid_table[i].last_error,
2388  "[%d] Expected last error to be %u, got %u\n",
2389  i, invalid_table[i].last_error, GetLastError());
2390  }
2391 
2392  count = 0xdeadbeef;
2393  ret = ReadConsoleOutputCharacterA(output_handle, NULL, 0, origin, &count);
2394  ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret);
2395  ok(count == 0, "Expected count to be 0, got %u\n", count);
2396 
2397  count = 0xdeadbeef;
2398  ret = ReadConsoleOutputCharacterA(output_handle, &read, 0, origin, &count);
2399  ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret);
2400  ok(count == 0, "Expected count to be 0, got %u\n", count);
2401 
2402  count = 0xdeadbeef;
2403  ret = ReadConsoleOutputCharacterA(output_handle, &read, 1, origin, &count);
2404  ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret);
2405  ok(count == 1, "Expected count to be 1, got %u\n", count);
2406 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
char CHAR
Definition: xmlstorage.h:175
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
voidpf uLong int origin
Definition: ioapi.h:142
char * LPSTR
Definition: xmlstorage.h:182
GLuint coord
Definition: glext.h:9511
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputCharacterA(IN HANDLE hConsoleOutput, OUT LPSTR lpCharacter, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCharsRead)
Definition: readwrite.c:1403
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
Definition: bl.h:1338
#define ok(value,...)
Definition: atltest.h:57
static int expected_count(int *sink)
uint32_t * LPDWORD
Definition: typedefs.h:57
static LPCSTR lpstr
Definition: font.c:51
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by START_TEST().

◆ test_ReadConsoleOutputCharacterW()

static void test_ReadConsoleOutputCharacterW ( HANDLE  output_handle)
static

Definition at line 2408 of file console.c.

2409 {
2410  WCHAR read;
2411  COORD origin = {0, 0};
2412  DWORD count;
2413  BOOL ret;
2414  int i;
2415 
2416  const struct
2417  {
2418  HANDLE hConsoleOutput;
2419  LPWSTR buffer;
2420  DWORD length;
2421  COORD coord;
2422  LPDWORD read_count;
2424  DWORD last_error;
2425  int win7_crash;
2426  } invalid_table[] =
2427  {
2428  {NULL, NULL, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2429  {NULL, NULL, 0, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2430  {NULL, NULL, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2431  {NULL, NULL, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE, 1},
2432  {NULL, &read, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2433  {NULL, &read, 0, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2434  {NULL, &read, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2435  {NULL, &read, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2436  {INVALID_HANDLE_VALUE, NULL, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2438  {INVALID_HANDLE_VALUE, NULL, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2439  {INVALID_HANDLE_VALUE, NULL, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE, 1},
2440  {INVALID_HANDLE_VALUE, &read, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2441  {INVALID_HANDLE_VALUE, &read, 0, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2442  {INVALID_HANDLE_VALUE, &read, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2443  {INVALID_HANDLE_VALUE, &read, 1, {0, 0}, &count, 0, ERROR_INVALID_HANDLE},
2444  {output_handle, NULL, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2445  {output_handle, NULL, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2446  {output_handle, NULL, 1, {0, 0}, &count, 1, ERROR_INVALID_ACCESS, 1},
2447  {output_handle, NULL, 10, {0, 0}, &count, 10, ERROR_INVALID_ACCESS, 1},
2448  {output_handle, &read, 0, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2449  {output_handle, &read, 1, {0, 0}, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1},
2450  };
2451 
2452  for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++)
2453  {
2454  if (invalid_table[i].win7_crash)
2455  continue;
2456 
2457  SetLastError(0xdeadbeef);
2458  if (invalid_table[i].read_count) count = 0xdeadbeef;
2459  ret = ReadConsoleOutputCharacterW(invalid_table[i].hConsoleOutput,
2460  invalid_table[i].buffer,
2461  invalid_table[i].length,
2462  invalid_table[i].coord,
2463  invalid_table[i].read_count);
2464  ok(!ret, "[%d] Expected ReadConsoleOutputCharacterW to return FALSE, got %d\n", i, ret);
2465  if (invalid_table[i].read_count)
2466  {
2467  ok(count == invalid_table[i].expected_count,
2468  "[%d] Expected count to be %u, got %u\n",
2469  i, invalid_table[i].expected_count, count);
2470  }
2471  ok(GetLastError() == invalid_table[i].last_error,
2472  "[%d] Expected last error to be %u, got %u\n",
2473  i, invalid_table[i].last_error, GetLastError());
2474  }
2475 
2476  count = 0xdeadbeef;
2477  ret = ReadConsoleOutputCharacterW(output_handle, NULL, 0, origin, &count);
2478  ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret);
2479  ok(count == 0, "Expected count to be 0, got %u\n", count);
2480 
2481  count = 0xdeadbeef;
2482  ret = ReadConsoleOutputCharacterW(output_handle, &read, 0, origin, &count);
2483  ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret);
2484  ok(count == 0, "Expected count to be 0, got %u\n", count);
2485 
2486  count = 0xdeadbeef;
2487  ret = ReadConsoleOutputCharacterW(output_handle, &read, 1, origin, &count);
2488  ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret);
2489  ok(count == 1, "Expected count to be 1, got %u\n", count);
2490 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
voidpf uLong int origin
Definition: ioapi.h:142
GLuint buffer
Definition: glext.h:5915
GLuint coord
Definition: glext.h:9511
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
Definition: bl.h:1338
#define ok(value,...)
Definition: atltest.h:57
static int expected_count(int *sink)
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputCharacterW(IN HANDLE hConsoleOutput, OUT LPWSTR lpCharacter, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCharsRead)
Definition: readwrite.c:1382
uint32_t * LPDWORD
Definition: typedefs.h:57
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by START_TEST().

◆ test_SetConsoleFont()

static void test_SetConsoleFont ( HANDLE  std_output)
static

Definition at line 2932 of file console.c.

2933 {
2934  HANDLE hmod;
2935  BOOL (WINAPI *pSetConsoleFont)(HANDLE, DWORD);
2936  BOOL ret;
2937  DWORD (WINAPI *pGetNumberOfConsoleFonts)(void);
2938  DWORD num_fonts;
2939 
2940  hmod = GetModuleHandleA("kernel32.dll");
2941  pSetConsoleFont = (void *)GetProcAddress(hmod, "SetConsoleFont");
2942  if (!pSetConsoleFont)
2943  {
2944  win_skip("SetConsoleFont is not available\n");
2945  return;
2946  }
2947 
2948  SetLastError(0xdeadbeef);
2949  ret = pSetConsoleFont(NULL, 0);
2950  ok(!ret, "got %d, expected zero\n", ret);
2951  todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2952 
2953  SetLastError(0xdeadbeef);
2954  ret = pSetConsoleFont(GetStdHandle(STD_INPUT_HANDLE), 0);
2955  ok(!ret, "got %d, expected zero\n", ret);
2956  todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
2957 
2958  pGetNumberOfConsoleFonts = (void *)GetProcAddress(hmod, "GetNumberOfConsoleFonts");
2959  if (!pGetNumberOfConsoleFonts)
2960  {
2961  win_skip("GetNumberOfConsoleFonts is not available\n");
2962  return;
2963  }
2964 
2965  num_fonts = pGetNumberOfConsoleFonts();
2966 
2967  SetLastError(0xdeadbeef);
2968  ret = pSetConsoleFont(std_output, num_fonts);
2969  ok(!ret, "got %d, expected zero\n", ret);
2970  todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
2971 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static BOOL
Definition: console.c:28
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
static HANDLE(WINAPI *pOpenConsoleW)(LPCWSTR
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define STD_INPUT_HANDLE
Definition: winbase.h:264
static DWORD
Definition: console.c:27
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define todo_wine
Definition: test.h:154
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define ok(value,...)
Definition: atltest.h:57
#define GetProcAddress(x, y)
Definition: compat.h:418
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_VerifyConsoleIoHandle()

static void test_VerifyConsoleIoHandle ( HANDLE  handle)
static

Definition at line 1279 of file console.c.

1280 {
1281  BOOL ret;
1282  DWORD error;
1283 
1284  if (!pVerifyConsoleIoHandle)
1285  {
1286  win_skip("VerifyConsoleIoHandle is not available\n");
1287  return;
1288  }
1289 
1290  /* invalid handle */
1291  SetLastError(0xdeadbeef);
1292  ret = pVerifyConsoleIoHandle((HANDLE)0xdeadbee0);
1293  error = GetLastError();
1294  ok(!ret, "expected VerifyConsoleIoHandle to fail\n");
1295  ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
1296 
1297  /* invalid handle + 1 */
1298  SetLastError(0xdeadbeef);
1299  ret = pVerifyConsoleIoHandle((HANDLE)0xdeadbee1);
1300  error = GetLastError();
1301  ok(!ret, "expected VerifyConsoleIoHandle to fail\n");
1302  ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
1303 
1304  /* invalid handle + 2 */
1305  SetLastError(0xdeadbeef);
1306  ret = pVerifyConsoleIoHandle((HANDLE)0xdeadbee2);
1307  error = GetLastError();
1308  ok(!ret, "expected VerifyConsoleIoHandle to fail\n");
1309  ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
1310 
1311  /* invalid handle + 3 */
1312  SetLastError(0xdeadbeef);
1313  ret = pVerifyConsoleIoHandle((HANDLE)0xdeadbee3);
1314  error = GetLastError();
1315  ok(!ret, "expected VerifyConsoleIoHandle to fail\n");
1316  ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
1317 
1318  /* valid handle */
1319  SetLastError(0xdeadbeef);
1320  ret = pVerifyConsoleIoHandle(handle);
1321  error = GetLastError();
1322  ok(ret ||
1323  broken(!ret), /* Windows 8 and 10 */
1324  "expected VerifyConsoleIoHandle to succeed\n");
1325  ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
1326 }
#define error(str)
Definition: mkdosfs.c:1605
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_WriteConsoleInputA()

static void test_WriteConsoleInputA ( HANDLE  input_handle)
static

Definition at line 1417 of file console.c.

1418 {
1420  INPUT_RECORD event_list[5];
1421  MOUSE_EVENT_RECORD mouse_event = { {0, 0}, 0, 0, MOUSE_MOVED };
1423  DWORD count, console_mode, gle;
1424  BOOL ret;
1425  int i;
1426 
1427  const struct
1428  {
1429  HANDLE handle;
1430  const INPUT_RECORD *buffer;
1431  DWORD count;
1432  LPDWORD written;
1433  DWORD gle, gle2;
1434  int win_crash;
1435  } invalid_table[] =
1436  {
1437  {NULL, NULL, 0, NULL, ERROR_INVALID_ACCESS, 0, 1},
1439  {NULL, NULL, 1, NULL, ERROR_INVALID_ACCESS, 0, 1},
1441  {NULL, &event, 0, NULL, ERROR_INVALID_ACCESS, 0, 1},
1443  {NULL, &event, 1, NULL, ERROR_INVALID_ACCESS, 0, 1},
1453  {input_handle, NULL, 0, NULL, ERROR_INVALID_ACCESS, 0, 1},
1454  {input_handle, NULL, 1, NULL, ERROR_INVALID_ACCESS, 0, 1},
1455  {input_handle, NULL, 1, &count, ERROR_NOACCESS, ERROR_INVALID_ACCESS},
1456  {input_handle, &event, 0, NULL, ERROR_INVALID_ACCESS, 0, 1},
1457  {input_handle, &event, 1, NULL, ERROR_INVALID_ACCESS, 0, 1},
1458  };
1459 
1460  /* Suppress external sources of input events for the duration of the test. */
1461  ret = GetConsoleMode(input_handle, &console_mode);
1462  ok(ret == TRUE, "Expected GetConsoleMode to return TRUE, got %d\n", ret);
1463  if (!ret)
1464  {
1465  skip("GetConsoleMode failed with last error %u\n", GetLastError());
1466  return;
1467  }
1468 
1469  ret = SetConsoleMode(input_handle, console_mode & ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT));
1470  ok(ret == TRUE, "Expected SetConsoleMode to return TRUE, got %d\n", ret);
1471  if (!ret)
1472  {
1473  skip("SetConsoleMode failed with last error %u\n", GetLastError());
1474  return;
1475  }
1476 
1477  /* Discard any events queued before the tests. */
1478  ret = FlushConsoleInputBuffer(input_handle);
1479  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1480 
1481  event.EventType = MOUSE_EVENT;
1482  event.Event.MouseEvent = mouse_event;
1483 
1484  for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++)
1485  {
1486  if (invalid_table[i].win_crash)
1487  continue;
1488 
1489  SetLastError(0xdeadbeef);
1490  if (invalid_table[i].written) count = 0xdeadbeef;
1491  ret = WriteConsoleInputA(invalid_table[i].handle,
1492  invalid_table[i].buffer,
1493  invalid_table[i].count,
1494  invalid_table[i].written);
1495  ok(!ret, "[%d] Expected WriteConsoleInputA to return FALSE, got %d\n", i, ret);
1496  gle = GetLastError();
1497  ok(gle == invalid_table[i].gle || (gle != 0 && gle == invalid_table[i].gle2),
1498  "[%d] Expected last error to be %u or %u, got %u\n",
1499  i, invalid_table[i].gle, invalid_table[i].gle2, gle);
1500  }
1501 
1502  count = 0xdeadbeef;
1503  ret = WriteConsoleInputA(input_handle, NULL, 0, &count);
1504  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1505  ok(count == 0, "Expected count to be 0, got %u\n", count);
1506 
1507  count = 0xdeadbeef;
1508  ret = WriteConsoleInputA(input_handle, &event, 0, &count);
1509  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1510  ok(count == 0, "Expected count to be 0, got %u\n", count);
1511 
1512  count = 0xdeadbeef;
1513  ret = WriteConsoleInputA(input_handle, &event, 1, &count);
1514  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1515  ok(count == 1, "Expected count to be 1, got %u\n", count);
1516 
1517  ret = FlushConsoleInputBuffer(input_handle);
1518  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1519 
1520  /* Writing a single mouse event doesn't seem to affect the count if an adjacent mouse event is already queued. */
1521  event.EventType = MOUSE_EVENT;
1522  event.Event.MouseEvent = mouse_event;
1523 
1524  ret = WriteConsoleInputA(input_handle, &event, 1, &count);
1525  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1526  ok(count == 1, "Expected count to be 1, got %u\n", count);
1527 
1528  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1529  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1530  ok(count == 1, "Expected count to be 1, got %u\n", count);
1531 
1532  ret = WriteConsoleInputA(input_handle, &event, 1, &count);
1533  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1534  ok(count == 1, "Expected count to be 1, got %u\n", count);
1535 
1536  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1537  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1538  todo_wine
1539  ok(count == 1, "Expected count to be 1, got %u\n", count);
1540 
1541  ret = FlushConsoleInputBuffer(input_handle);
1542  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1543 
1544  for (i = 0; i < sizeof(event_list)/sizeof(event_list[0]); i++)
1545  {
1546  event_list[i].EventType = MOUSE_EVENT;
1547  event_list[i].Event.MouseEvent = mouse_event;
1548  }
1549 
1550  /* Writing consecutive chunks of mouse events appears to work. */
1551  ret = WriteConsoleInputA(input_handle, event_list, sizeof(event_list)/sizeof(event_list[0]), &count);
1552  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1553  ok(count == sizeof(event_list)/sizeof(event_list[0]),
1554  "Expected count to be event list length, got %u\n", count);
1555 
1556  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1557  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1558  ok(count == sizeof(event_list)/sizeof(event_list[0]),
1559  "Expected count to be event list length, got %u\n", count);
1560 
1561  ret = WriteConsoleInputA(input_handle, event_list, sizeof(event_list)/sizeof(event_list[0]), &count);
1562  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1563  ok(count == sizeof(event_list)/sizeof(event_list[0]),
1564  "Expected count to be event list length, got %u\n", count);
1565 
1566  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1567  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1568  ok(count == 2*sizeof(event_list)/sizeof(event_list[0]),
1569  "Expected count to be twice event list length, got %u\n", count);
1570 
1571  /* Again, writing a single mouse event with adjacent mouse events queued doesn't appear to affect the count. */
1572  ret = WriteConsoleInputA(input_handle, &event, 1, &count);
1573  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1574  ok(count == 1, "Expected count to be 1, got %u\n", count);
1575 
1576  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1577  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1578  todo_wine
1579  ok(count == 2*sizeof(event_list)/sizeof(event_list[0]),
1580  "Expected count to be twice event list length, got %u\n", count);
1581 
1582  ret = FlushConsoleInputBuffer(input_handle);
1583  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1584 
1585  key_event.bKeyDown = FALSE;
1586  key_event.wRepeatCount = 0;
1587  key_event.wVirtualKeyCode = VK_SPACE;
1588  key_event.wVirtualScanCode = VK_SPACE;
1589  key_event.uChar.AsciiChar = ' ';
1590  key_event.dwControlKeyState = 0;
1591 
1592  event.EventType = KEY_EVENT;
1593  event.Event.KeyEvent = key_event;
1594 
1595  /* Key events don't exhibit the same behavior as mouse events. */
1596  ret = WriteConsoleInputA(input_handle, &event, 1, &count);
1597  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1598  ok(count == 1, "Expected count to be 1, got %u\n", count);
1599 
1600  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1601  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1602  ok(count == 1, "Expected count to be 1, got %u\n", count);
1603 
1604  ret = WriteConsoleInputA(input_handle, &event, 1, &count);
1605  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1606  ok(count == 1, "Expected count to be 1, got %u\n", count);
1607 
1608  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1609  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1610  ok(count == 2, "Expected count to be 2, got %u\n", count);
1611 
1612  ret = FlushConsoleInputBuffer(input_handle);
1613  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1614 
1615  /* Try interleaving mouse and key events. */
1616  event.EventType = MOUSE_EVENT;
1617  event.Event.MouseEvent = mouse_event;
1618 
1619  ret = WriteConsoleInputA(input_handle, &event, 1, &count);
1620  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1621  ok(count == 1, "Expected count to be 1, got %u\n", count);
1622 
1623  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1624  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1625  ok(count == 1, "Expected count to be 1, got %u\n", count);
1626 
1627  event.EventType = KEY_EVENT;
1628  event.Event.KeyEvent = key_event;
1629 
1630  ret = WriteConsoleInputA(input_handle, &event, 1, &count);
1631  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1632  ok(count == 1, "Expected count to be 1, got %u\n", count);
1633 
1634  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1635  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1636  ok(count == 2, "Expected count to be 2, got %u\n", count);
1637 
1638  event.EventType = MOUSE_EVENT;
1639  event.Event.MouseEvent = mouse_event;
1640 
1641  ret = WriteConsoleInputA(input_handle, &event, 1, &count);
1642  ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
1643  ok(count == 1, "Expected count to be 1, got %u\n", count);
1644 
1645  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1646  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1647  ok(count == 3, "Expected count to be 3, got %u\n", count);
1648 
1649  /* Restore the old console mode. */
1650  ret = SetConsoleMode(input_handle, console_mode);
1651  ok(ret == TRUE, "Expected SetConsoleMode to return TRUE, got %d\n", ret);
1652 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
BOOL WINAPI FlushConsoleInputBuffer(IN HANDLE hConsoleInput)
Definition: console.c:169
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define MOUSE_MOVED
Definition: wincon.h:153
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ERROR_NOACCESS
Definition: winerror.h:578
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
#define KEY_EVENT
Definition: wincon.h:122
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputA(IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten)
Definition: readwrite.c:1511
#define MOUSE_EVENT
Definition: wincon.h:123
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#define ENABLE_MOUSE_INPUT
Definition: wincon.h:79
int ret
#define todo_wine
Definition: test.h:154
BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE hConsoleInput, LPDWORD lpNumberOfEvents)
Definition: console.c:1637
#define ENABLE_WINDOW_INPUT
Definition: wincon.h:78
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
struct _cl_event * event
Definition: glext.h:7739
void key_event(int scancode, int pressed)
Definition: svgawin.c:773
#define ok(value,...)
Definition: atltest.h:57
#define VK_SPACE
Definition: winuser.h:2194
WORD EventType
Definition: wincon.h:261
#define skip(...)
Definition: atltest.h:64
MOUSE_EVENT_RECORD MouseEvent
Definition: wincon.h:264
uint32_t * LPDWORD
Definition: typedefs.h:57
union _INPUT_RECORD::@3176 Event

Referenced by START_TEST().

◆ test_WriteConsoleInputW()

static void test_WriteConsoleInputW ( HANDLE  input_handle)
static

Definition at line 1654 of file console.c.

1655 {
1657  INPUT_RECORD event_list[5];
1658  MOUSE_EVENT_RECORD mouse_event = { {0, 0}, 0, 0, MOUSE_MOVED };
1660  DWORD count, console_mode, gle;
1661  BOOL ret;
1662  int i;
1663 
1664  const struct
1665  {
1666  HANDLE handle;
1667  const INPUT_RECORD *buffer;
1668  DWORD count;
1669  LPDWORD written;
1670  DWORD gle, gle2;
1671  int win_crash;
1672  } invalid_table[] =
1673  {
1674  {NULL, NULL, 0, NULL, ERROR_INVALID_ACCESS, 0, 1},
1676  {NULL, NULL, 1, NULL, ERROR_INVALID_ACCESS, 0, 1},
1678  {NULL, &event, 0, NULL, ERROR_INVALID_ACCESS, 0, 1},
1680  {NULL, &event, 1, NULL, ERROR_INVALID_ACCESS, 0, 1},
1690  {input_handle, NULL, 0, NULL, ERROR_INVALID_ACCESS, 0, 1},
1691  {input_handle, NULL, 1, NULL, ERROR_INVALID_ACCESS, 0, 1},
1692  {input_handle, NULL, 1, &count, ERROR_NOACCESS, ERROR_INVALID_ACCESS},
1693  {input_handle, &event, 0, NULL, ERROR_INVALID_ACCESS, 0, 1},
1694  {input_handle, &event, 1, NULL, ERROR_INVALID_ACCESS, 0, 1},
1695  };
1696 
1697  /* Suppress external sources of input events for the duration of the test. */
1698  ret = GetConsoleMode(input_handle, &console_mode);
1699  ok(ret == TRUE, "Expected GetConsoleMode to return TRUE, got %d\n", ret);
1700  if (!ret)
1701  {
1702  skip("GetConsoleMode failed with last error %u\n", GetLastError());
1703  return;
1704  }
1705 
1706  ret = SetConsoleMode(input_handle, console_mode & ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT));
1707  ok(ret == TRUE, "Expected SetConsoleMode to return TRUE, got %d\n", ret);
1708  if (!ret)
1709  {
1710  skip("SetConsoleMode failed with last error %u\n", GetLastError());
1711  return;
1712  }
1713 
1714  /* Discard any events queued before the tests. */
1715  ret = FlushConsoleInputBuffer(input_handle);
1716  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1717 
1718  event.EventType = MOUSE_EVENT;
1719  event.Event.MouseEvent = mouse_event;
1720 
1721  for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++)
1722  {
1723  if (invalid_table[i].win_crash)
1724  continue;
1725 
1726  SetLastError(0xdeadbeef);
1727  if (invalid_table[i].written) count = 0xdeadbeef;
1728  ret = WriteConsoleInputW(invalid_table[i].handle,
1729  invalid_table[i].buffer,
1730  invalid_table[i].count,
1731  invalid_table[i].written);
1732  ok(!ret, "[%d] Expected WriteConsoleInputW to return FALSE, got %d\n", i, ret);
1733  gle = GetLastError();
1734  ok(gle == invalid_table[i].gle || (gle != 0 && gle == invalid_table[i].gle2),
1735  "[%d] Expected last error to be %u or %u, got %u\n",
1736  i, invalid_table[i].gle, invalid_table[i].gle2, gle);
1737  }
1738 
1739  count = 0xdeadbeef;
1740  ret = WriteConsoleInputW(input_handle, NULL, 0, &count);
1741  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1742  ok(count == 0, "Expected count to be 0, got %u\n", count);
1743 
1744  count = 0xdeadbeef;
1745  ret = WriteConsoleInputW(input_handle, &event, 0, &count);
1746  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1747  ok(count == 0, "Expected count to be 0, got %u\n", count);
1748 
1749  count = 0xdeadbeef;
1750  ret = WriteConsoleInputW(input_handle, &event, 1, &count);
1751  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1752  ok(count == 1, "Expected count to be 1, got %u\n", count);
1753 
1754  ret = FlushConsoleInputBuffer(input_handle);
1755  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1756 
1757  /* Writing a single mouse event doesn't seem to affect the count if an adjacent mouse event is already queued. */
1758  event.EventType = MOUSE_EVENT;
1759  event.Event.MouseEvent = mouse_event;
1760 
1761  ret = WriteConsoleInputW(input_handle, &event, 1, &count);
1762  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1763  ok(count == 1, "Expected count to be 1, got %u\n", count);
1764 
1765  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1766  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1767  ok(count == 1, "Expected count to be 1, got %u\n", count);
1768 
1769  ret = WriteConsoleInputW(input_handle, &event, 1, &count);
1770  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1771  ok(count == 1, "Expected count to be 1, got %u\n", count);
1772 
1773  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1774  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1775  todo_wine
1776  ok(count == 1, "Expected count to be 1, got %u\n", count);
1777 
1778  ret = FlushConsoleInputBuffer(input_handle);
1779  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1780 
1781  for (i = 0; i < sizeof(event_list)/sizeof(event_list[0]); i++)
1782  {
1783  event_list[i].EventType = MOUSE_EVENT;
1784  event_list[i].Event.MouseEvent = mouse_event;
1785  }
1786 
1787  /* Writing consecutive chunks of mouse events appears to work. */
1788  ret = WriteConsoleInputW(input_handle, event_list, sizeof(event_list)/sizeof(event_list[0]), &count);
1789  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1790  ok(count == sizeof(event_list)/sizeof(event_list[0]),
1791  "Expected count to be event list length, got %u\n", count);
1792 
1793  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1794  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1795  ok(count == sizeof(event_list)/sizeof(event_list[0]),
1796  "Expected count to be event list length, got %u\n", count);
1797 
1798  ret = WriteConsoleInputW(input_handle, event_list, sizeof(event_list)/sizeof(event_list[0]), &count);
1799  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1800  ok(count == sizeof(event_list)/sizeof(event_list[0]),
1801  "Expected count to be event list length, got %u\n", count);
1802 
1803  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1804  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1805  ok(count == 2*sizeof(event_list)/sizeof(event_list[0]),
1806  "Expected count to be twice event list length, got %u\n", count);
1807 
1808  /* Again, writing a single mouse event with adjacent mouse events queued doesn't appear to affect the count. */
1809  ret = WriteConsoleInputW(input_handle, &event, 1, &count);
1810  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1811  ok(count == 1, "Expected count to be 1, got %u\n", count);
1812 
1813  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1814  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1815  todo_wine
1816  ok(count == 2*sizeof(event_list)/sizeof(event_list[0]),
1817  "Expected count to be twice event list length, got %u\n", count);
1818 
1819  ret = FlushConsoleInputBuffer(input_handle);
1820  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1821 
1822  key_event.bKeyDown = FALSE;
1823  key_event.wRepeatCount = 0;
1824  key_event.wVirtualKeyCode = VK_SPACE;
1825  key_event.wVirtualScanCode = VK_SPACE;
1826  key_event.uChar.UnicodeChar = ' ';
1827  key_event.dwControlKeyState = 0;
1828 
1829  event.EventType = KEY_EVENT;
1830  event.Event.KeyEvent = key_event;
1831 
1832  /* Key events don't exhibit the same behavior as mouse events. */
1833  ret = WriteConsoleInputW(input_handle, &event, 1, &count);
1834  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1835  ok(count == 1, "Expected count to be 1, got %u\n", count);
1836 
1837  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1838  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1839  ok(count == 1, "Expected count to be 1, got %u\n", count);
1840 
1841  ret = WriteConsoleInputW(input_handle, &event, 1, &count);
1842  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1843  ok(count == 1, "Expected count to be 1, got %u\n", count);
1844 
1845  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
1846  ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
1847  ok(count == 2, "Expected count to be 2, got %u\n", count);
1848 
1849  ret = FlushConsoleInputBuffer(input_handle);
1850  ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
1851 
1852  /* Try interleaving mouse and key events. */
1853  event.EventType = MOUSE_EVENT;
1854  event.Event.MouseEvent = mouse_event;
1855 
1856  ret = WriteConsoleInputW(input_handle, &event, 1, &count);
1857  ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
1858  ok(count == 1, "Expected count to be 1, got %u\n", count);
1859 
1860  ret = GetNumberOfConsoleInputEvents(input_handle, &count);
<