sync shell32_winetest with wine 1.1.27
[reactos.git] / rostests / winetests / shell32 / shfldr_special.c
1 /*
2 * Tests for special shell folders
3 *
4 * Copyright 2008 Robert Shearman for CodeWeavers
5 * Copyright 2008 Owen Rudge
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #define COBJMACROS
26 #define WIN32_LEAN_AND_MEAN
27 #include <windows.h>
28 #include "shellapi.h"
29 #include "shlobj.h"
30
31 #include "wine/test.h"
32
33 /* Tests for My Network Places */
34 static void test_parse_for_entire_network(void)
35 {
36 static WCHAR my_network_places_path[] = {
37 ':',':','{','2','0','8','D','2','C','6','0','-','3','A','E','A','-',
38 '1','0','6','9','-','A','2','D','7','-','0','8','0','0','2','B','3','0','3','0','9','D','}', 0 };
39 static WCHAR entire_network_path[] = {
40 ':',':','{','2','0','8','D','2','C','6','0','-','3','A','E','A','-',
41 '1','0','6','9','-','A','2','D','7','-','0','8','0','0','2','B','3','0','3','0','9','D',
42 '}','\\','E','n','t','i','r','e','N','e','t','w','o','r','k',0 };
43 IShellFolder *psfDesktop;
44 HRESULT hr;
45 DWORD eaten = 0xdeadbeef;
46 LPITEMIDLIST pidl;
47 DWORD attr = ~0;
48 DWORD expected_attr;
49
50 hr = SHGetDesktopFolder(&psfDesktop);
51 ok(hr == S_OK, "SHGetDesktopFolder failed with error 0x%x\n", hr);
52
53 hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, my_network_places_path, &eaten, &pidl, &attr);
54 ok(hr == S_OK, "IShellFolder_ParseDisplayName failed with error 0x%x\n", hr);
55 todo_wine
56 ok(eaten == 0xdeadbeef, "eaten should not have been set to %u\n", eaten);
57 expected_attr = SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET|SFGAO_CANRENAME|SFGAO_CANLINK;
58 todo_wine
59 ok((attr == expected_attr) || /* Win9x, NT4 */
60 (attr == (expected_attr | SFGAO_STREAM)) || /* W2K */
61 (attr == (expected_attr | SFGAO_CANDELETE)) || /* XP, W2K3 */
62 (attr == (expected_attr | SFGAO_CANDELETE | SFGAO_NONENUMERATED)), /* Vista */
63 "Unexpected attributes : %08x\n", attr);
64
65 ILFree(pidl);
66
67 /* Start clean again */
68 eaten = 0xdeadbeef;
69 attr = ~0;
70
71 hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, entire_network_path, &eaten, &pidl, &attr);
72 if (hr == HRESULT_FROM_WIN32(ERROR_BAD_NET_NAME) ||
73 hr == HRESULT_FROM_WIN32(ERROR_NO_NET_OR_BAD_PATH) ||
74 hr == HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER))
75 {
76 win_skip("'EntireNetwork' is not available on Win9x, NT4 and Vista\n");
77 return;
78 }
79 ok(hr == S_OK, "IShellFolder_ParseDisplayName failed with error 0x%x\n", hr);
80 todo_wine
81 ok(eaten == 0xdeadbeef, "eaten should not have been set to %u\n", eaten);
82 expected_attr = SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|SFGAO_HASPROPSHEET|SFGAO_CANLINK;
83 todo_wine
84 ok(attr == expected_attr || /* winme, nt4 */
85 attr == (expected_attr | SFGAO_STREAM) || /* win2k */
86 attr == (expected_attr | SFGAO_STORAGEANCESTOR), /* others */
87 "attr should be 0x%x, not 0x%x\n", expected_attr, attr);
88
89 ILFree(pidl);
90 }
91
92 /* Tests for Control Panel */
93 static void test_parse_for_control_panel(void)
94 {
95 /* path of My Computer\Control Panel */
96 static WCHAR control_panel_path[] = {
97 ':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}','\\',
98 ':',':','{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}', 0 };
99 IShellFolder *psfDesktop;
100 HRESULT hr;
101 DWORD eaten = 0xdeadbeef;
102 LPITEMIDLIST pidl;
103 DWORD attr = ~0;
104
105 hr = SHGetDesktopFolder(&psfDesktop);
106 ok(hr == S_OK, "SHGetDesktopFolder failed with error 0x%x\n", hr);
107
108 hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, control_panel_path, &eaten, &pidl, &attr);
109 ok(hr == S_OK, "IShellFolder_ParseDisplayName failed with error 0x%x\n", hr);
110 todo_wine ok(eaten == 0xdeadbeef, "eaten should not have been set to %u\n", eaten);
111 todo_wine
112 ok((attr == (SFGAO_CANLINK | SFGAO_FOLDER)) || /* Win9x, NT4 */
113 (attr == (SFGAO_CANLINK | SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_STREAM)) || /* W2K */
114 (attr == (SFGAO_CANLINK | SFGAO_FOLDER | SFGAO_HASSUBFOLDER)) || /* W2K, XP, W2K3 */
115 (attr == (SFGAO_CANLINK | SFGAO_NONENUMERATED)) || /* Vista */
116 (attr == SFGAO_CANLINK), /* Vista, W2K8 */
117 "Unexpected attributes : %08x\n", attr);
118
119 ILFree(pidl);
120 }
121
122
123 START_TEST(shfldr_special)
124 {
125 test_parse_for_entire_network();
126 test_parse_for_control_panel();
127 }