2005-01-20 21:03:13 +01:00
|
|
|
/*
|
|
|
|
* Unit tests for advpack.dll
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Robert Reif
|
2005-04-27 11:37:25 +02:00
|
|
|
* Copyright (C) 2005 Sami Aario
|
2005-01-20 21:03:13 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
2005-02-14 12:02:46 +01:00
|
|
|
#include <advpub.h>
|
2005-04-27 11:37:25 +02:00
|
|
|
#include <assert.h>
|
2005-01-20 21:03:13 +01:00
|
|
|
#include "wine/test.h"
|
2005-02-14 12:02:46 +01:00
|
|
|
|
|
|
|
static HRESULT (WINAPI *pGetVersionFromFile)(LPSTR,LPDWORD,LPDWORD,BOOL);
|
2005-04-27 11:37:25 +02:00
|
|
|
static HRESULT (WINAPI *pDelNode)(LPCSTR,DWORD);
|
2005-01-20 21:03:13 +01:00
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void version_test(void)
|
2005-01-20 21:03:13 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD major, minor;
|
|
|
|
|
|
|
|
major = minor = 0;
|
2005-02-14 12:02:46 +01:00
|
|
|
hr = pGetVersionFromFile("kernel32.dll", &major, &minor, FALSE);
|
2005-01-20 21:03:13 +01:00
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
|
|
|
|
"0x%08lx\n", hr);
|
|
|
|
|
|
|
|
trace("kernel32.dll Language ID: 0x%08lx, Codepage ID: 0x%08lx\n",
|
|
|
|
major, minor);
|
|
|
|
|
|
|
|
major = minor = 0;
|
2005-02-14 12:02:46 +01:00
|
|
|
hr = pGetVersionFromFile("kernel32.dll", &major, &minor, TRUE);
|
2005-01-20 21:03:13 +01:00
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
|
|
|
|
"0x%08lx\n", hr);
|
|
|
|
|
|
|
|
trace("kernel32.dll version: %d.%d.%d.%d\n", HIWORD(major), LOWORD(major),
|
|
|
|
HIWORD(minor), LOWORD(minor));
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void delnode_test(void)
|
2005-04-27 11:37:25 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HANDLE hn;
|
|
|
|
CHAR currDir[MAX_PATH];
|
|
|
|
int currDirLen;
|
|
|
|
|
|
|
|
/* Native DelNode apparently does not support relative paths, so we use
|
|
|
|
absolute paths for testing */
|
|
|
|
currDirLen = GetCurrentDirectoryA(sizeof(currDir) / sizeof(CHAR), currDir);
|
|
|
|
assert(currDirLen > 0 && currDirLen < sizeof(currDir) / sizeof(CHAR));
|
|
|
|
|
|
|
|
/* Simple tests; these should fail. */
|
|
|
|
hr = pDelNode(NULL, 0);
|
|
|
|
ok (hr == E_FAIL, "DelNode called with NULL pathname should return E_FAIL\n");
|
|
|
|
hr = pDelNode("", 0);
|
|
|
|
ok (hr == E_FAIL, "DelNode called with empty pathname should return E_FAIL\n");
|
|
|
|
|
|
|
|
/* Test deletion of a file. */
|
|
|
|
hn = CreateFile("DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hr = pDelNode(lstrcat(currDir, "\\DelNodeTestFile1"), 0);
|
|
|
|
ok (hr == S_OK, "DelNode failed deleting a single file\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
|
|
|
|
/* Test deletion of an empty directory. */
|
|
|
|
CreateDirectoryA("DelNodeTestDir", NULL);
|
|
|
|
hr = pDelNode(lstrcat(currDir, "\\DelNodeTestDir"), 0);
|
|
|
|
ok (hr == S_OK, "DelNode failed deleting an empty directory\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
|
|
|
|
/* Test deletion of a directory containing one file. */
|
|
|
|
CreateDirectoryA("DelNodeTestDir", NULL);
|
|
|
|
hn = CreateFile("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hr = pDelNode(lstrcat(currDir, "\\DelNodeTestDir"), 0);
|
|
|
|
ok (hr == S_OK, "DelNode failed deleting a directory containing one file\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
|
|
|
|
/* Test deletion of a directory containing multiple files. */
|
|
|
|
CreateDirectoryA("DelNodeTestDir", NULL);
|
|
|
|
hn = CreateFile("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hn = CreateFile("DelNodeTestDir\\DelNodeTestFile2", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hn = CreateFile("DelNodeTestDir\\DelNodeTestFile3", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
|
|
|
hr = pDelNode(lstrcat(currDir, "\\DelNodeTestDir"), 0);
|
|
|
|
ok (hr == S_OK, "DelNode failed deleting a directory containing multiple files\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
}
|
|
|
|
|
2005-01-20 21:03:13 +01:00
|
|
|
START_TEST(advpack)
|
|
|
|
{
|
2005-02-14 12:02:46 +01:00
|
|
|
HMODULE hdll;
|
|
|
|
|
|
|
|
hdll = LoadLibraryA("advpack.dll");
|
|
|
|
if (!hdll)
|
|
|
|
return;
|
2005-04-27 11:37:25 +02:00
|
|
|
|
2005-02-14 12:02:46 +01:00
|
|
|
pGetVersionFromFile = (void*)GetProcAddress(hdll, "GetVersionFromFile");
|
2005-04-27 11:37:25 +02:00
|
|
|
pDelNode = (void*)GetProcAddress(hdll, "DelNode");
|
|
|
|
if (!pGetVersionFromFile || !pDelNode)
|
2005-02-14 12:02:46 +01:00
|
|
|
return;
|
|
|
|
|
2005-01-20 21:03:13 +01:00
|
|
|
version_test();
|
2005-04-27 11:37:25 +02:00
|
|
|
delnode_test();
|
|
|
|
|
|
|
|
FreeLibrary(hdll);
|
2005-01-20 21:03:13 +01:00
|
|
|
}
|