2 * Unit tests for advpack.dll
4 * Copyright (C) 2005 Robert Reif
5 * Copyright (C) 2005 Sami Aario
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "wine/test.h"
27 static HRESULT (WINAPI
*pGetVersionFromFile
)(LPSTR
,LPDWORD
,LPDWORD
,BOOL
);
28 static HRESULT (WINAPI
*pDelNode
)(LPCSTR
,DWORD
);
30 static void version_test()
36 hr
= pGetVersionFromFile("kernel32.dll", &major
, &minor
, FALSE
);
37 ok (hr
== S_OK
, "GetVersionFromFileEx(kernel32.dll) failed, returned "
40 trace("kernel32.dll Language ID: 0x%08lx, Codepage ID: 0x%08lx\n",
44 hr
= pGetVersionFromFile("kernel32.dll", &major
, &minor
, TRUE
);
45 ok (hr
== S_OK
, "GetVersionFromFileEx(kernel32.dll) failed, returned "
48 trace("kernel32.dll version: %d.%d.%d.%d\n", HIWORD(major
), LOWORD(major
),
49 HIWORD(minor
), LOWORD(minor
));
52 static void delnode_test()
56 CHAR currDir
[MAX_PATH
];
59 /* Native DelNode apparently does not support relative paths, so we use
60 absolute paths for testing */
61 currDirLen
= GetCurrentDirectoryA(sizeof(currDir
) / sizeof(CHAR
), currDir
);
62 assert(currDirLen
> 0 && currDirLen
< sizeof(currDir
) / sizeof(CHAR
));
64 /* Simple tests; these should fail. */
65 hr
= pDelNode(NULL
, 0);
66 ok (hr
== E_FAIL
, "DelNode called with NULL pathname should return E_FAIL\n");
68 ok (hr
== E_FAIL
, "DelNode called with empty pathname should return E_FAIL\n");
70 /* Test deletion of a file. */
71 hn
= CreateFile("DelNodeTestFile1", GENERIC_WRITE
, 0, NULL
,
72 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
73 assert(hn
!= INVALID_HANDLE_VALUE
);
75 hr
= pDelNode(lstrcat(currDir
, "\\DelNodeTestFile1"), 0);
76 ok (hr
== S_OK
, "DelNode failed deleting a single file\n");
77 currDir
[currDirLen
] = '\0';
79 /* Test deletion of an empty directory. */
80 CreateDirectoryA("DelNodeTestDir", NULL
);
81 hr
= pDelNode(lstrcat(currDir
, "\\DelNodeTestDir"), 0);
82 ok (hr
== S_OK
, "DelNode failed deleting an empty directory\n");
83 currDir
[currDirLen
] = '\0';
85 /* Test deletion of a directory containing one file. */
86 CreateDirectoryA("DelNodeTestDir", NULL
);
87 hn
= CreateFile("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE
, 0, NULL
,
88 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
89 assert(hn
!= INVALID_HANDLE_VALUE
);
91 hr
= pDelNode(lstrcat(currDir
, "\\DelNodeTestDir"), 0);
92 ok (hr
== S_OK
, "DelNode failed deleting a directory containing one file\n");
93 currDir
[currDirLen
] = '\0';
95 /* Test deletion of a directory containing multiple files. */
96 CreateDirectoryA("DelNodeTestDir", NULL
);
97 hn
= CreateFile("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE
, 0, NULL
,
98 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
99 assert(hn
!= INVALID_HANDLE_VALUE
);
101 hn
= CreateFile("DelNodeTestDir\\DelNodeTestFile2", GENERIC_WRITE
, 0, NULL
,
102 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
103 assert(hn
!= INVALID_HANDLE_VALUE
);
105 hn
= CreateFile("DelNodeTestDir\\DelNodeTestFile3", GENERIC_WRITE
, 0, NULL
,
106 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
107 assert(hn
!= INVALID_HANDLE_VALUE
);
109 hr
= pDelNode(lstrcat(currDir
, "\\DelNodeTestDir"), 0);
110 ok (hr
== S_OK
, "DelNode failed deleting a directory containing multiple files\n");
111 currDir
[currDirLen
] = '\0';
118 hdll
= LoadLibraryA("advpack.dll");
122 pGetVersionFromFile
= (void*)GetProcAddress(hdll
, "GetVersionFromFile");
123 pDelNode
= (void*)GetProcAddress(hdll
, "DelNode");
124 if (!pGetVersionFromFile
|| !pDelNode
)