ntoskrnl.exe: Initial stub version with forwards to existing functions.
[wine/testsucceed.git] / dlls / hlink / tests / hlink.c
blob8854e79196e66c3c4a2a23edd90c1262c8b79b59
1 /*
2 * Implementation of hyperlinking (hlink.dll)
4 * Copyright 2006 Mike McCormack
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include <hlink.h>
24 #include <hlguids.h>
26 #include "wine/test.h"
28 static void test_HlinkIsShortcut(void)
30 int i;
31 HRESULT hres;
33 static const WCHAR file0[] = {'f','i','l','e',0};
34 static const WCHAR file1[] = {'f','i','l','e','.','u','r','l',0};
35 static const WCHAR file2[] = {'f','i','l','e','.','l','n','k',0};
36 static const WCHAR file3[] = {'f','i','l','e','.','u','R','l',0};
37 static const WCHAR file4[] = {'f','i','l','e','u','r','l',0};
38 static const WCHAR file5[] = {'c',':','\\','f','i','l','e','.','u','r','l',0};
39 static const WCHAR file6[] = {'c',':','\\','f','i','l','e','.','l','n','k',0};
40 static const WCHAR file7[] = {'.','u','r','l',0};
42 static struct {
43 LPCWSTR file;
44 HRESULT hres;
45 } shortcut_test[] = {
46 {file0, S_FALSE},
47 {file1, S_OK},
48 {file2, S_FALSE},
49 {file3, S_OK},
50 {file4, S_FALSE},
51 {file5, S_OK},
52 {file6, S_FALSE},
53 {file7, S_OK},
54 {NULL, E_INVALIDARG}
57 for(i=0; i<sizeof(shortcut_test)/sizeof(shortcut_test[0]); i++) {
58 hres = HlinkIsShortcut(shortcut_test[i].file);
59 ok(hres == shortcut_test[i].hres, "[%d] HlinkIsShortcut returned %08x, expected %08x\n",
60 i, hres, shortcut_test[i].hres);
64 START_TEST(hlink)
66 HRESULT r;
67 IHlink *lnk = NULL;
68 IMoniker *mk = NULL;
69 const WCHAR url[] = { 'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',0 };
70 const WCHAR url2[] = { 'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g','/',0 };
71 LPWSTR str = NULL;
73 CoInitialize(NULL);
75 r = HlinkCreateFromString(url, NULL, NULL, NULL,
76 0, NULL, &IID_IHlink, (LPVOID*) &lnk);
77 ok(r == S_OK, "failed to create link\n");
78 if (FAILED(r))
79 return;
81 r = IHlink_GetMonikerReference(lnk, HLINKGETREF_DEFAULT, NULL, NULL);
82 ok(r == S_OK, "failed\n");
84 r = IHlink_GetMonikerReference(lnk, HLINKGETREF_DEFAULT, &mk, &str);
85 ok(r == S_OK, "failed\n");
86 ok(mk != NULL, "no moniker\n");
87 ok(str == NULL, "string should be null\n");
89 r = IMoniker_Release(mk);
90 ok( r == 1, "moniker refcount wrong\n");
92 r = IHlink_GetStringReference(lnk, -1, &str, NULL);
93 ok(r == S_OK, "failed\n");
95 r = IHlink_GetStringReference(lnk, HLINKGETREF_DEFAULT, &str, NULL);
96 ok(r == S_OK, "failed\n");
97 todo_wine {
98 ok(!lstrcmpW(str, url2), "url wrong\n");
100 CoTaskMemFree(str);
102 r = IHlink_GetStringReference(lnk, HLINKGETREF_DEFAULT, NULL, NULL);
103 ok(r == S_OK, "failed\n");
105 r = IHlink_GetStringReference(lnk, HLINKGETREF_DEFAULT, NULL, &str);
106 ok(r == S_OK, "failed\n");
107 ok(str == NULL, "string should be null\n");
109 test_HlinkIsShortcut();