1 /* Unit test suite for SHLWAPI IQueryAssociations functions
3 * Copyright 2008 Google (Lei Zhang)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
25 #define expect(expected, got) ok ( expected == got, "Expected %d, got %d\n", expected, got)
26 #define expect_hr(expected, got) ok ( expected == got, "Expected %08x, got %08x\n", expected, got)
28 /* Every version of Windows with IE should have this association? */
29 static const WCHAR dotHtml[] = { '.','h','t','m','l',0 };
30 static const WCHAR badBad[] = { 'b','a','d','b','a','d',0 };
31 static const WCHAR dotBad[] = { '.','b','a','d',0 };
32 static const WCHAR open[] = { 'o','p','e','n',0 };
33 static const WCHAR invalid[] = { 'i','n','v','a','l','i','d',0 };
35 static void test_getstring_bad(void)
40 hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, NULL, open, NULL, &len);
41 todo_wine expect_hr(E_INVALIDARG, hr);
42 hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, badBad, open, NULL, &len);
43 todo_wine expect_hr(E_FAIL, hr);
44 hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotBad, open, NULL, &len);
45 todo_wine expect_hr(E_FAIL, hr);
46 hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, invalid, NULL,
48 todo_wine expect_hr(0x80070002, hr); /* NOT FOUND */
49 hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open, NULL, NULL);
50 todo_wine expect_hr(E_UNEXPECTED, hr);
52 hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, NULL, open, NULL, &len);
53 todo_wine expect_hr(E_INVALIDARG, hr);
54 hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, badBad, open, NULL,
56 todo_wine expect_hr(E_FAIL, hr);
57 hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotBad, open, NULL,
59 todo_wine expect_hr(E_FAIL, hr);
60 hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, invalid, NULL,
62 todo_wine expect_hr(0x80070002, hr); /* NOT FOUND */
63 hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL,
65 todo_wine expect_hr(E_UNEXPECTED, hr);
68 static void test_getstring_basic(void)
72 WCHAR * executableName;
73 DWORD len, len2, slen;
75 hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open, NULL, &len);
76 todo_wine expect_hr(S_FALSE, hr);
79 skip("failed to get initial len\n");
83 executableName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
87 skip("failed to allocate memory\n");
92 hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open,
93 executableName, &len2);
95 slen = lstrlenW(executableName) + 1;
99 hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL,
101 expect_hr(S_FALSE, hr);
104 HeapFree(GetProcessHeap(), 0, executableName);
105 skip("failed to get initial len\n");
109 friendlyName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
110 len * sizeof(WCHAR));
113 HeapFree(GetProcessHeap(), 0, executableName);
114 skip("failed to allocate memory\n");
119 hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open,
120 friendlyName, &len2);
122 slen = lstrlenW(friendlyName) + 1;
126 HeapFree(GetProcessHeap(), 0, executableName);
127 HeapFree(GetProcessHeap(), 0, friendlyName);
132 test_getstring_bad();
133 test_getstring_basic();