ReactOS 0.4.16-dev-306-g647d351
assoc.c File Reference
#include <stdarg.h>
#include "wine/test.h"
#include "shlwapi.h"
#include "shlguid.h"
Include dependency graph for assoc.c:

Go to the source code of this file.

Classes

struct  assoc_test_struct
 

Macros

#define expect(expected, got)   ok( (expected) == (got), "Expected %d, got %d\n", (expected), (got))
 
#define expect_hr(expected, got)   ok( (expected) == (got), "Expected %08x, got %08x\n", (expected), (got))
 
#define HARDCODED_NATIVE_WMSDK   (PERCEIVEDFLAG_HARDCODED | PERCEIVEDFLAG_NATIVESUPPORT | PERCEIVEDFLAG_WMSDK)
 
#define HARDCODED_NATIVE_GDIPLUS   (PERCEIVEDFLAG_HARDCODED | PERCEIVEDFLAG_NATIVESUPPORT | PERCEIVEDFLAG_GDIPLUS)
 
#define HARDCODED_NATIVE_ZIPFLDR   (PERCEIVEDFLAG_HARDCODED | PERCEIVEDFLAG_NATIVESUPPORT | PERCEIVEDFLAG_ZIPFOLDER)
 
#define SOFTCODED_NATIVESUPPORT   (PERCEIVEDFLAG_SOFTCODED | PERCEIVEDFLAG_NATIVESUPPORT)
 

Functions

static HRESULT (WINAPI *pAssocQueryStringA)(ASSOCF
 
static void test_getstring_bad (void)
 
static void test_getstring_basic (void)
 
static void test_getstring_no_extra (void)
 
static void test_assoc_create (void)
 
static void test_assoc_one (const struct assoc_test_struct *test)
 
static void test_assoc_perceived (void)
 
 START_TEST (assoc)
 

Variables

static ASSOCSTR
 
static LPCSTR
 
static LPSTR
 
static LPDWORD = NULL
 
static LPCWSTR
 
static LPWSTR
 
static REFIID
 
static void **static PERCEIVED INT LPWSTR *static const WCHAR dotHtml [] = { '.','h','t','m','l',0 }
 
static const WCHAR badBad [] = { 'b','a','d','b','a','d',0 }
 
static const WCHAR dotBad [] = { '.','b','a','d',0 }
 
static const WCHAR open [] = { 'o','p','e','n',0 }
 
static const WCHAR invalid [] = { 'i','n','v','a','l','i','d',0 }
 
static const struct assoc_test_struct assoc_perceived_types []
 

Macro Definition Documentation

◆ expect

#define expect (   expected,
  got 
)    ok( (expected) == (got), "Expected %d, got %d\n", (expected), (got))

Definition at line 26 of file assoc.c.

◆ expect_hr

#define expect_hr (   expected,
  got 
)    ok( (expected) == (got), "Expected %08x, got %08x\n", (expected), (got))

Definition at line 27 of file assoc.c.

◆ HARDCODED_NATIVE_GDIPLUS

#define HARDCODED_NATIVE_GDIPLUS   (PERCEIVEDFLAG_HARDCODED | PERCEIVEDFLAG_NATIVESUPPORT | PERCEIVEDFLAG_GDIPLUS)

Definition at line 322 of file assoc.c.

◆ HARDCODED_NATIVE_WMSDK

#define HARDCODED_NATIVE_WMSDK   (PERCEIVEDFLAG_HARDCODED | PERCEIVEDFLAG_NATIVESUPPORT | PERCEIVEDFLAG_WMSDK)

Definition at line 321 of file assoc.c.

◆ HARDCODED_NATIVE_ZIPFLDR

#define HARDCODED_NATIVE_ZIPFLDR   (PERCEIVEDFLAG_HARDCODED | PERCEIVEDFLAG_NATIVESUPPORT | PERCEIVEDFLAG_ZIPFOLDER)

Definition at line 323 of file assoc.c.

◆ SOFTCODED_NATIVESUPPORT

#define SOFTCODED_NATIVESUPPORT   (PERCEIVEDFLAG_SOFTCODED | PERCEIVEDFLAG_NATIVESUPPORT)

Definition at line 324 of file assoc.c.

Function Documentation

◆ HRESULT()

static HRESULT ( WINAPI pAssocQueryStringA)
static

◆ START_TEST()

START_TEST ( assoc  )

Definition at line 587 of file assoc.c.

588{
590 hshlwapi = GetModuleHandleA("shlwapi.dll");
591 pAssocQueryStringA = (void*)GetProcAddress(hshlwapi, "AssocQueryStringA");
592 pAssocQueryStringW = (void*)GetProcAddress(hshlwapi, "AssocQueryStringW");
593 pAssocCreate = (void*)GetProcAddress(hshlwapi, "AssocCreate");
594 pAssocGetPerceivedType = (void*)GetProcAddress(hshlwapi, "AssocGetPerceivedType");
595
601}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_getstring_basic(void)
Definition: assoc.c:126
static void test_getstring_bad(void)
Definition: assoc.c:41
static void test_assoc_create(void)
Definition: assoc.c:271
static void test_getstring_no_extra(void)
Definition: assoc.c:197
static void test_assoc_perceived(void)
Definition: assoc.c:531
static HMODULE hshlwapi
Definition: shreg.c:35

◆ test_assoc_create()

static void test_assoc_create ( void  )
static

Definition at line 271 of file assoc.c.

272{
273 HRESULT hr;
274 IQueryAssociations *pqa;
275
276 if (!pAssocCreate)
277 {
278 win_skip("AssocCreate() is missing\n");
279 return;
280 }
281
282 hr = pAssocCreate(IID_NULL, &IID_NULL, NULL);
283 ok(hr == E_INVALIDARG, "Unexpected result : %08x\n", hr);
284
285 hr = pAssocCreate(CLSID_QueryAssociations, &IID_NULL, (LPVOID*)&pqa);
287 , "Unexpected result : %08x\n", hr);
288
289 hr = pAssocCreate(IID_NULL, &IID_IQueryAssociations, (LPVOID*)&pqa);
291 , "Unexpected result : %08x\n", hr);
292
293 hr = pAssocCreate(CLSID_QueryAssociations, &IID_IQueryAssociations, (LPVOID*)&pqa);
294 ok(hr == S_OK || hr == E_NOTIMPL /* win98 */
295 , "Unexpected result : %08x\n", hr);
296 if(hr == S_OK)
297 {
299 }
300
301 hr = pAssocCreate(CLSID_QueryAssociations, &IID_IUnknown, (LPVOID*)&pqa);
302 ok(hr == S_OK || hr == E_NOTIMPL /* win98 */
303 , "Unexpected result : %08x\n", hr);
304 if(hr == S_OK)
305 {
307 }
308}
#define ok(value,...)
Definition: atltest.h:57
const GUID IID_IUnknown
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define S_OK
Definition: intsafe.h:52
#define IID_NULL
Definition: guiddef.h:98
#define win_skip
Definition: test.h:163
HRESULT hr
Definition: shlfolder.c:183
#define IQueryAssociations_Release(p)
Definition: shlwapi.h:694
#define E_NOINTERFACE
Definition: winerror.h:2364
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663

Referenced by START_TEST().

◆ test_assoc_one()

static void test_assoc_one ( const struct assoc_test_struct test)
static

Definition at line 478 of file assoc.c.

479{
480 LPWSTR extension, type_expected, type_returned;
481 PERCEIVED perceived;
482 HRESULT hr;
483 INT flags;
484
485 /* if SHStrDupA receives a nullptr as input, it will null the output */
486 SHStrDupA(test->extension, &extension);
487 SHStrDupA(test->type, &type_expected);
488
489 perceived = 0xdeadbeef;
490 flags = 0xdeadbeef;
491
492 hr = pAssocGetPerceivedType(extension, &perceived, &flags, NULL);
493 expect_hr(type_expected ? S_OK : test->hr, hr);
494 ok(perceived == test->perceived, "%s: got perceived 0x%x, expected 0x%x\n",
495 test->extension, perceived, test->perceived);
496 ok(flags == test->flags, "%s: got flags 0x%x, expected 0x%x\n",
497 test->extension, flags, test->flags);
498
499 type_returned = (void *)0xdeadbeef;
500 perceived = 0xdeadbeef;
501 flags = 0xdeadbeef;
502
503 hr = pAssocGetPerceivedType(extension, &perceived, &flags, &type_returned);
504 expect_hr(type_expected ? S_OK : test->hr, hr);
505 ok(perceived == test->perceived, "%s: got perceived 0x%x, expected 0x%x\n",
506 test->extension, perceived, test->perceived);
507 ok(flags == test->flags, "%s: got flags 0x%x, expected 0x%x\n",
508 test->extension, flags, test->flags);
509
510 if (!type_expected)
511 {
512 ok(type_returned == (void *)0xdeadbeef || broken(type_returned == NULL) /* Win 8 */,
513 "%s: got type %p, expected 0xdeadbeef\n", test->extension, type_returned);
514 }
515 else if (type_returned == (void *)0xdeadbeef)
516 {
517 ok(type_returned != (void *)0xdeadbeef, "%s: got type %p, expected '%s'\n",
518 test->extension, type_returned, test->type);
519 }
520 else
521 {
522 ok(StrCmpIW(type_expected, type_returned) == 0, "%s: got type %s, expected '%s'\n",
523 test->extension, wine_dbgstr_w(type_returned), test->type);
524 }
525
526 CoTaskMemFree(type_returned);
527 CoTaskMemFree(extension);
528 CoTaskMemFree(type_expected);
529}
#define broken(x)
Definition: atltest.h:178
HRESULT WINAPI SHStrDupA(LPCSTR lpszStr, LPWSTR *lppszDest)
Definition: string.c:1960
int WINAPI StrCmpIW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:353
GLbitfield flags
Definition: glext.h:7161
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define wine_dbgstr_w
Definition: kernel32.h:34
#define expect_hr(expected, got)
Definition: assoc.c:27
#define test
Definition: rosglue.h:37
enum tagPERCEIVED PERCEIVED
int32_t INT
Definition: typedefs.h:58
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by test_assoc_perceived().

◆ test_assoc_perceived()

static void test_assoc_perceived ( void  )
static

Definition at line 531 of file assoc.c.

532{
533 static const struct assoc_test_struct should_not_exist =
534 { ".should_not_exist", PERCEIVED_TYPE_UNSPECIFIED, PERCEIVEDFLAG_UNDEFINED, NULL, 0, 0x80070002 };
535 static const struct assoc_test_struct htm[] =
536 {
537 { ".htm", PERCEIVED_TYPE_TEXT, SOFTCODED_NATIVESUPPORT, "text", 0x600 },
538 { ".html", PERCEIVED_TYPE_TEXT, SOFTCODED_NATIVESUPPORT, "text", 0x600 },
539 };
540 static const struct assoc_test_struct mp2 =
541 { ".mp2", PERCEIVED_TYPE_VIDEO, HARDCODED_NATIVE_WMSDK, "video" };
542
545 size_t i;
546
547 if (!pAssocGetPerceivedType)
548 {
549 win_skip("AssocGetPerceivedType() is missing\n");
550 return;
551 }
552
553 memset(&osvi, 0, sizeof(osvi));
554 osvi.dwOSVersionInfoSize = sizeof(osvi);
557
558 /* invalid entry results in HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) */
559 test_assoc_one(&should_not_exist);
560
561 for (i = 0; i < sizeof(assoc_perceived_types) / sizeof(assoc_perceived_types[0]); ++i)
562 {
564 continue;
565 if (!(assoc_perceived_types[i].flags & PERCEIVEDFLAG_HARDCODED))
567 else
569 }
570
571 /* below Vista */
572 if (version < 0x600)
573 {
575 test_assoc_one(&htm[0]);
577 test_assoc_one(&htm[1]);
578 }
579
580 /* below Win8 */
581 if (version < 0x602)
582 {
583 test_assoc_one(&mp2);
584 }
585}
static const WCHAR version[]
Definition: asmname.c:66
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
#define SOFTCODED_NATIVESUPPORT
Definition: assoc.c:237
#define HARDCODED_NATIVE_WMSDK
Definition: assoc.c:234
unsigned long DWORD
Definition: ntddk_ex.h:95
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 todo_wine
Definition: custom.c:89
static const struct assoc_test_struct assoc_perceived_types[]
Definition: assoc.c:326
static void test_assoc_one(const struct assoc_test_struct *test)
Definition: assoc.c:478
#define memset(x, y, z)
Definition: compat.h:39
@ PERCEIVED_TYPE_TEXT
Definition: shtypes.idl:173
@ PERCEIVED_TYPE_UNSPECIFIED
Definition: shtypes.idl:170
@ PERCEIVED_TYPE_VIDEO
Definition: shtypes.idl:176
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:237
ULONG dwMajorVersion
Definition: rtltypes.h:238
ULONG dwMinorVersion
Definition: rtltypes.h:239
DWORD minversion
Definition: assoc.c:317
OSVERSIONINFO osvi
Definition: ver.c:28

Referenced by START_TEST().

◆ test_getstring_bad()

static void test_getstring_bad ( void  )
static

Definition at line 41 of file assoc.c.

42{
43 static const WCHAR openwith[] = {'O','p','e','n','W','i','t','h','.','e','x','e',0};
45 HRESULT hr;
46 DWORD len;
47
48 if (!pAssocQueryStringW)
49 {
50 win_skip("AssocQueryStringW() is missing\n");
51 return;
52 }
53
54 len = 0xdeadbeef;
55 hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, NULL, open, NULL, &len);
57 ok(len == 0xdeadbeef, "got %u\n", len);
58
59 len = 0xdeadbeef;
60 hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, badBad, open, NULL, &len);
61 ok(hr == E_FAIL ||
62 hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION), /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
63 "Unexpected result : %08x\n", hr);
64 ok(len == 0xdeadbeef, "got %u\n", len);
65
67 hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotBad, open, buf, &len);
68 ok(hr == E_FAIL ||
69 hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */ ||
70 hr == S_OK /* Win8 */,
71 "Unexpected result : %08x\n", hr);
72 if (hr == S_OK)
73 {
74 ok(len < ARRAY_SIZE(buf), "got %u\n", len);
75 ok(!lstrcmpiW(buf + len - ARRAY_SIZE(openwith), openwith), "wrong data\n");
76 }
77
78 len = 0xdeadbeef;
79 hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, invalid, NULL, &len);
81 hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION), /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
82 "Unexpected result : %08x\n", hr);
83 ok(len == 0xdeadbeef, "got %u\n", len);
84
85 hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open, NULL, NULL);
86 ok(hr == E_UNEXPECTED ||
87 hr == E_INVALIDARG, /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
88 "Unexpected result : %08x\n", hr);
89
90 len = 0xdeadbeef;
91 hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, NULL, open, NULL, &len);
93 ok(len == 0xdeadbeef, "got %u\n", len);
94
95 len = 0xdeadbeef;
96 hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, badBad, open, NULL, &len);
97 ok(hr == E_FAIL ||
98 hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION), /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
99 "Unexpected result : %08x\n", hr);
100 ok(len == 0xdeadbeef, "got %u\n", len);
101
102 len = 0xdeadbeef;
103 hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotBad, open, NULL, &len);
104 ok(hr == E_FAIL ||
105 hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */ ||
106 hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND) /* Win8 */ ||
107 hr == S_FALSE, /* Win10 */
108 "Unexpected result : %08x\n", hr);
109 ok((hr == S_FALSE && len < ARRAY_SIZE(buf)) || len == 0xdeadbeef,
110 "got hr=%08x and len=%u\n", hr, len);
111
112 len = 0xdeadbeef;
113 hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, invalid, NULL, &len);
115 hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) || /* W2K/Vista/W2K8 */
116 hr == E_FAIL, /* Win9x/WinMe/NT4 */
117 "Unexpected result : %08x\n", hr);
118 ok(len == 0xdeadbeef, "got %u\n", len);
119
120 hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL, NULL);
121 ok(hr == E_UNEXPECTED ||
122 hr == E_INVALIDARG, /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
123 "Unexpected result : %08x\n", hr);
124}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define E_FAIL
Definition: ddrawi.h:102
#define MAX_PATH
Definition: compat.h:34
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static const WCHAR badBad[]
Definition: assoc.c:36
static const WCHAR open[]
Definition: assoc.c:38
static const WCHAR dotBad[]
Definition: assoc.c:37
static const WCHAR invalid[]
Definition: assoc.c:39
static void **static PERCEIVED INT LPWSTR *static const WCHAR dotHtml[]
Definition: assoc.c:35
@ ASSOCSTR_FRIENDLYAPPNAME
Definition: shlwapi.h:606
@ ASSOCSTR_EXECUTABLE
Definition: shlwapi.h:604
#define S_FALSE
Definition: winerror.h:2357
#define ERROR_NO_ASSOCIATION
Definition: winerror.h:677
#define E_UNEXPECTED
Definition: winerror.h:2456
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_NOT_FOUND
Definition: winerror.h:690
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_getstring_basic()

static void test_getstring_basic ( void  )
static

Definition at line 126 of file assoc.c.

127{
128 HRESULT hr;
129 WCHAR * friendlyName;
130 WCHAR * executableName;
131 DWORD len, len2, slen;
132
133 if (!pAssocQueryStringW)
134 {
135 win_skip("AssocQueryStringW() is missing\n");
136 return;
137 }
138
139 hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open, NULL, &len);
141 if (hr != S_FALSE)
142 {
143 skip("failed to get initial len\n");
144 return;
145 }
146
147 executableName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
148 len * sizeof(WCHAR));
149 if (!executableName)
150 {
151 skip("failed to allocate memory\n");
152 return;
153 }
154
155 len2 = len;
156 hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open,
157 executableName, &len2);
158 expect_hr(S_OK, hr);
159 slen = lstrlenW(executableName) + 1;
160 expect(len, len2);
161 expect(len, slen);
162
163 hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL,
164 &len);
165 ok(hr == S_FALSE ||
166 hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) /* Win9x/NT4 */ ||
168 "Unexpected result : %08x\n", hr);
169 if (hr != S_FALSE)
170 {
171 HeapFree(GetProcessHeap(), 0, executableName);
172 skip("failed to get initial len\n");
173 return;
174 }
175
176 friendlyName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
177 len * sizeof(WCHAR));
178 if (!friendlyName)
179 {
180 HeapFree(GetProcessHeap(), 0, executableName);
181 skip("failed to allocate memory\n");
182 return;
183 }
184
185 len2 = len;
186 hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open,
187 friendlyName, &len2);
188 expect_hr(S_OK, hr);
189 slen = lstrlenW(friendlyName) + 1;
190 expect(len, len2);
191 expect(len, slen);
192
193 HeapFree(GetProcessHeap(), 0, executableName);
194 HeapFree(GetProcessHeap(), 0, friendlyName);
195}
#define skip(...)
Definition: atltest.h:64
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define lstrlenW
Definition: compat.h:750
#define expect(expected, got)
Definition: assoc.c:26

Referenced by START_TEST().

◆ test_getstring_no_extra()

static void test_getstring_no_extra ( void  )
static

Definition at line 197 of file assoc.c.

198{
199 LONG ret;
200 HKEY hkey;
201 HRESULT hr;
202 static const CHAR dotWinetest[] = {
203 '.','w','i','n','e','t','e','s','t',0
204 };
205 static const CHAR winetestfile[] = {
206 'w','i','n','e','t','e','s','t', 'f','i','l','e',0
207 };
208 static const CHAR winetestfileAction[] = {
209 'w','i','n','e','t','e','s','t','f','i','l','e',
210 '\\','s','h','e','l','l',
211 '\\','f','o','o',
212 '\\','c','o','m','m','a','n','d',0
213 };
214 static const CHAR action[] = {
215 'n','o','t','e','p','a','d','.','e','x','e',0
216 };
219
220 if (!pAssocQueryStringA)
221 {
222 win_skip("AssocQueryStringA() is missing\n");
223 return;
224 }
225
226 buf[0] = '\0';
227 ret = RegCreateKeyA(HKEY_CLASSES_ROOT, dotWinetest, &hkey);
228 if (ret != ERROR_SUCCESS) {
229 skip("failed to create dotWinetest key\n");
230 return;
231 }
232
233 ret = RegSetValueA(hkey, NULL, REG_SZ, winetestfile, lstrlenA(winetestfile));
234 RegCloseKey(hkey);
235 if (ret != ERROR_SUCCESS)
236 {
237 skip("failed to set dotWinetest key\n");
238 goto cleanup;
239 }
240
241 ret = RegCreateKeyA(HKEY_CLASSES_ROOT, winetestfileAction, &hkey);
242 if (ret != ERROR_SUCCESS)
243 {
244 skip("failed to create winetestfileAction key\n");
245 goto cleanup;
246 }
247
249 RegCloseKey(hkey);
250 if (ret != ERROR_SUCCESS)
251 {
252 skip("failed to set winetestfileAction key\n");
253 goto cleanup;
254 }
255
256 hr = pAssocQueryStringA(0, ASSOCSTR_EXECUTABLE, dotWinetest, NULL, buf, &len);
257 ok(hr == S_OK ||
258 hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP and W2K3 */
259 "Unexpected result : %08x\n", hr);
260 hr = pAssocQueryStringA(0, ASSOCSTR_EXECUTABLE, dotWinetest, "foo", buf, &len);
261 expect_hr(S_OK, hr);
262 ok(strstr(buf, action) != NULL,
263 "got '%s' (Expected result to include 'notepad.exe')\n", buf);
264
265cleanup:
266 SHDeleteKeyA(HKEY_CLASSES_ROOT, dotWinetest);
267 SHDeleteKeyA(HKEY_CLASSES_ROOT, winetestfile);
268
269}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1179
LONG WINAPI RegSetValueA(HKEY hKeyOriginal, LPCSTR lpSubKey, DWORD dwType, LPCSTR lpData, DWORD cbData)
Definition: reg.c:4954
static void cleanup(void)
Definition: main.c:1335
const WCHAR * action
Definition: action.c:7509
DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey)
Definition: reg.c:1533
#define REG_SZ
Definition: layer.c:22
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
long LONG
Definition: pedump.c:60
int ret
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

Variable Documentation

◆ assoc_perceived_types

const struct assoc_test_struct assoc_perceived_types[]
static

Definition at line 326 of file assoc.c.

Referenced by test_assoc_perceived().

◆ ASSOCSTR

Definition at line 29 of file assoc.c.

◆ badBad

const WCHAR badBad[] = { 'b','a','d','b','a','d',0 }
static

Definition at line 36 of file assoc.c.

Referenced by test_getstring_bad().

◆ dotBad

const WCHAR dotBad[] = { '.','b','a','d',0 }
static

Definition at line 37 of file assoc.c.

Referenced by test_getstring_bad().

◆ dotHtml

void **static PERCEIVED INT LPWSTR* static const WCHAR dotHtml[] = { '.','h','t','m','l',0 }
static

Definition at line 35 of file assoc.c.

Referenced by test_getstring_bad(), and test_getstring_basic().

◆ invalid

◆ LPCSTR

Definition at line 29 of file assoc.c.

◆ LPCWSTR

Definition at line 30 of file assoc.c.

◆ LPDWORD

Definition at line 29 of file assoc.c.

◆ LPSTR

Definition at line 29 of file assoc.c.

◆ LPWSTR

Definition at line 30 of file assoc.c.

◆ open

const WCHAR open[] = { 'o','p','e','n',0 }
static

Definition at line 38 of file assoc.c.

Referenced by test_getstring_bad(), and test_getstring_basic().

◆ REFIID

REFIID

Definition at line 31 of file assoc.c.