ReactOS 0.4.17-dev-769-g1500a35
registrar.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <wine/test.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <winnls.h>
#include <winerror.h>
#include <winnt.h>
#include <wtypes.h>
#include <olectl.h>
#include <ocidl.h>
#include <initguid.h>
#include <atliface.h>
Include dependency graph for registrar.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static void test_registrar (void)
 
static void test_aggregation (void)
 
 START_TEST (registrar)
 

Variables

static const char textA []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file registrar.c.

Function Documentation

◆ START_TEST()

START_TEST ( registrar  )

Definition at line 185 of file registrar.c.

186{
188
191
193}
#define NULL
Definition: types.h:112
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
static void test_registrar(void)
Definition: registrar.c:61
static void test_aggregation(void)
Definition: registrar.c:173

◆ test_aggregation()

static void test_aggregation ( void  )
static

Definition at line 173 of file registrar.c.

174{
175 IUnknown *unk = (IUnknown*)0xdeadbeef;
177
178 hres = CoCreateInstance(&CLSID_Registrar, (IUnknown*)0xdeadbeef, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
179 &IID_IUnknown, (void**)&unk);
181 "CoCreateInstance failed: %08lx, expected CLASS_E_NOAGGREGATION\n", hres);
182 ok(!unk || unk == (IUnknown*)0xdeadbeef, "unk = %p\n", unk);
183}
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
const GUID IID_IUnknown
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
HRESULT hres
Definition: protocol.c:465
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771

Referenced by START_TEST(), test_filter_graph_aggregations(), test_filter_mapper_aggregations(), test_null_renderer_aggregations(), and test_video_renderer_aggregations().

◆ test_registrar()

static void test_registrar ( void  )
static

Definition at line 61 of file registrar.c.

62{
63 IRegistrar *registrar = NULL;
64 HRESULT hr;
65 INT count;
66 int i;
67 WCHAR *textW = NULL;
68 struct dword_test
69 {
70 const char *name;
71 BOOL preserved;
73 } dword_tests[] =
74 {
75 { "dword_unquoted_dec", TRUE, 1 },
76 { "dword_quoted_dec", TRUE, 1 },
77 { "dword_quoted_hex", FALSE, 0xA },
78 { "dword_unquoted_hex", FALSE, 0xA },
79 { "dword_negative", FALSE, -2147483648 },
80 { "dword_ulong", TRUE, 2147483649 },
81 { "dword_max", TRUE, 4294967295 },
82 { "dword_overrange", FALSE, 4294967296 },
83 };
84
85 if (!GetProcAddress(GetModuleHandleA("atl.dll"), "AtlAxAttachControl"))
86 {
87 win_skip("Old versions of atl.dll don't support binary values\n");
88 return;
89 }
90
91 hr = CoCreateInstance(&CLSID_Registrar, NULL, CLSCTX_INPROC_SERVER, &IID_IRegistrar, (void**)&registrar);
92 if (FAILED(hr))
93 {
94 win_skip("creating IRegistrar failed, hr = 0x%08lX\n", hr);
95 return;
96 }
97
99 textW = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
100 if (textW)
101 {
102 DWORD dword;
103 DWORD size;
104 LONG lret;
105 HKEY key;
106 BYTE bytes[4];
107 char buffer[16];
108
110 hr = IRegistrar_StringRegister(registrar, textW);
111 ok(hr == S_OK, "StringRegister failed: %08lx\n", hr);
112 if (FAILED(hr))
113 {
114 IRegistrar_Release(registrar);
115 return;
116 }
117
118 lret = RegOpenKeyA(HKEY_CURRENT_USER, "eebf73c4-50fd-478f-bbcf-db212221227a", &key);
119 ok(lret == ERROR_SUCCESS, "error %ld opening registry key\n", lret);
120
121 size = sizeof(buffer);
122 lret = RegQueryValueExA(key, "str1", NULL, NULL, (BYTE*)buffer, &size);
123 ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %ld\n", lret);
124 ok(!strcmp( buffer, "string"), "wrong data %s\n", debugstr_a(buffer));
125
126 size = sizeof(buffer);
127 lret = RegQueryValueExA(key, "str2", NULL, NULL, (BYTE*)buffer, &size);
128 ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %ld\n", lret);
129 ok(!strcmp( buffer, "str\\\"ing"), "wrong data %s\n", debugstr_a(buffer));
130
131 size = sizeof(buffer);
132 lret = RegQueryValueExA(key, "str3", NULL, NULL, (BYTE*)buffer, &size);
133 ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %ld\n", lret);
134 ok(!strcmp( buffer, "str'ing"), "wrong data %s\n", debugstr_a(buffer));
135
136 for (i = 0; i < ARRAYSIZE(dword_tests); i++)
137 {
138 size = sizeof(dword);
139 lret = RegQueryValueExA(key, dword_tests[i].name, NULL, NULL, (BYTE*)&dword, &size);
140 ok(lret == ERROR_SUCCESS, "Test %d: RegQueryValueExA failed %ld.\n", i, lret);
141 if (dword_tests[i].preserved)
142 ok(dword == dword_tests[i].value, "Test %d: got unexpected value %lu.\n", i, dword);
143 else
144 ok(dword != dword_tests[i].value, "Test %d: is not supposed to be preserved.\n", i);
145 }
146
147 size = 4;
148 lret = RegQueryValueExA(key, "binary_quoted", NULL, NULL, bytes, &size);
149 ok(lret == ERROR_SUCCESS, "RegQueryValueA, failed, error %ld\n", lret);
150 ok(bytes[0] == 0xde && bytes[1] == 0xad && bytes[2] == 0xbe && bytes[3] == 0xef,
151 "binary quoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
152 0xff & bytes[0], 0xff & bytes[1], 0xff & bytes[2], 0xff & bytes[3]);
153
154 size = 4;
155 lret = RegQueryValueExA(key, "binary_unquoted", NULL, NULL, bytes, &size);
156 ok(lret == ERROR_SUCCESS, "RegQueryValueA, failed, error %ld\n", lret);
157 ok(bytes[0] == 0xde && bytes[1] == 0xad && bytes[2] == 0x01 && bytes[3] == 0x23,
158 "binary unquoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
159 0xff & bytes[0], 0xff & bytes[1], 0xff & bytes[2], 0xff & bytes[3]);
160
161 hr = IRegistrar_StringUnregister(registrar, textW);
162 ok(SUCCEEDED(hr), "IRegistrar_StringUnregister failed, hr = 0x%08lX\n", hr);
164
166 }
167 else
168 skip("allocating memory failed\n");
169
170 IRegistrar_Release(registrar);
171}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define skip(...)
Definition: atltest.h:64
#define RegCloseKey(hKey)
Definition: registry.h:49
HRESULT hr
Definition: delayimp.cpp:582
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
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:4009
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
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 S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_a
Definition: kernel32.h:31
#define win_skip
Definition: minitest.h:67
static const char textA[]
Definition: registrar.c:40
static const WCHAR textW[]
Definition: itemdlg.c:1559
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
Definition: copy.c:22
Definition: name.c:39
int64_t LONGLONG
Definition: typedefs.h:68
int32_t INT
Definition: typedefs.h:58
Definition: pdh_main.c:96
#define HKEY_CURRENT_USER
Definition: winreg.h:11
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

Variable Documentation

◆ textA

const char textA[]
static
Initial value:
=
"HKCU \n"
"{ \n"
" ForceRemove eebf73c4-50fd-478f-bbcf-db212221227a \n"
" { \n"
" val 'str1' = s 'string' \n"
" val 'str2' = s 'str\\\"ing' \n"
" val 'str3' = s 'str''ing' \n"
" val 'dword_quoted_dec' = d '1' \n"
" val 'dword_unquoted_dec' = d 1 \n"
" val 'dword_quoted_hex' = d '0xA' \n"
" val 'dword_unquoted_hex' = d 0xA \n"
" val 'dword_negative' = d -2147483648 \n"
" val 'dword_ulong' = d 2147483649 \n"
" val 'dword_max' = d 4294967295 \n"
" val 'dword_overrange' = d 4294967296 \n"
" val 'binary_quoted' = b 'deadbeef' \n"
" val 'binary_unquoted' = b dead0123 \n"
" } \n"
"}"

Definition at line 40 of file registrar.c.

Referenced by EDIT_CallWordBreakProc(), EDIT_EM_GetHandle(), EDIT_EM_SetHandle(), EDIT_LockBuffer(), EDIT_WM_GetText(), EDIT_WM_SetText(), EditWndProc_common(), ListBoxWndProc_common(), parent_wnd_proc(), RichEditWndProc_common(), test_aw_conversion_dlgprocA(), test_aw_conversion_dlgprocW(), test_aw_conversion_wndproc(), test_comboex_get_set_item(), test_header_notification(), test_header_notification2(), and test_registrar().