Added YUV routines needed for v4l driver, and in the future possibly
[wine/gsoc-2012-control.git] / dlls / advpack / tests / advpack.c
blob854eeafb60a0e71e67324c32ef9af047524a965d
1 /*
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
22 #include <windows.h>
23 #include <advpub.h>
24 #include <assert.h>
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()
32 HRESULT hr;
33 DWORD major, minor;
35 major = minor = 0;
36 hr = pGetVersionFromFile("kernel32.dll", &major, &minor, FALSE);
37 ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
38 "0x%08lx\n", hr);
40 trace("kernel32.dll Language ID: 0x%08lx, Codepage ID: 0x%08lx\n",
41 major, minor);
43 major = minor = 0;
44 hr = pGetVersionFromFile("kernel32.dll", &major, &minor, TRUE);
45 ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
46 "0x%08lx\n", hr);
48 trace("kernel32.dll version: %d.%d.%d.%d\n", HIWORD(major), LOWORD(major),
49 HIWORD(minor), LOWORD(minor));
52 static void delnode_test()
54 HRESULT hr;
55 HANDLE hn;
56 CHAR currDir[MAX_PATH];
57 int currDirLen;
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");
67 hr = pDelNode("", 0);
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);
74 CloseHandle(hn);
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);
90 CloseHandle(hn);
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);
100 CloseHandle(hn);
101 hn = CreateFile("DelNodeTestDir\\DelNodeTestFile2", GENERIC_WRITE, 0, NULL,
102 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
103 assert(hn != INVALID_HANDLE_VALUE);
104 CloseHandle(hn);
105 hn = CreateFile("DelNodeTestDir\\DelNodeTestFile3", GENERIC_WRITE, 0, NULL,
106 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
107 assert(hn != INVALID_HANDLE_VALUE);
108 CloseHandle(hn);
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';
114 START_TEST(advpack)
116 HMODULE hdll;
118 hdll = LoadLibraryA("advpack.dll");
119 if (!hdll)
120 return;
122 pGetVersionFromFile = (void*)GetProcAddress(hdll, "GetVersionFromFile");
123 pDelNode = (void*)GetProcAddress(hdll, "DelNode");
124 if (!pGetVersionFromFile || !pDelNode)
125 return;
127 version_test();
128 delnode_test();
130 FreeLibrary(hdll);