2 * Unit tests for SetupIterateCabinet
4 * Copyright 2007 Hans Leidekker
5 * Copyright 2010 Andrew Nguyen
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/test.h"
32 static void create_source_fileA(LPSTR filename, const BYTE *data, DWORD size)
37 handle = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
38 FILE_ATTRIBUTE_NORMAL, NULL);
39 WriteFile(handle, data, size, &written, NULL);
43 static UINT CALLBACK dummy_callbackA(PVOID Context, UINT Notification,
44 UINT_PTR Param1, UINT_PTR Param2)
46 ok(0, "Received unexpected notification (%p, %u, %lu, %lu)\n", Context,
47 Notification, Param1, Param2);
51 static void test_invalid_parametersA(void)
54 char source[MAX_PATH], temp[MAX_PATH];
60 PSP_FILE_CALLBACK MsgHandler;
61 DWORD expected_lasterror;
63 } invalid_parameters[] =
65 {NULL, NULL, ERROR_INVALID_PARAMETER},
66 {NULL, dummy_callbackA, ERROR_INVALID_PARAMETER},
67 {"c:\\nonexistent.cab", NULL, ERROR_FILE_NOT_FOUND},
68 {"c:\\nonexistent.cab", dummy_callbackA, ERROR_FILE_NOT_FOUND},
69 {source, NULL, ERROR_INVALID_DATA, 1},
70 {source, dummy_callbackA, ERROR_INVALID_DATA, 1},
73 GetTempPathA(sizeof(temp), temp);
74 GetTempFileNameA(temp, "doc", 0, source);
76 create_source_fileA(source, NULL, 0);
78 for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
80 SetLastError(0xdeadbeef);
81 ret = SetupIterateCabinetA(invalid_parameters[i].CabinetFile, 0,
82 invalid_parameters[i].MsgHandler, NULL);
83 ok(!ret, "[%d] Expected SetupIterateCabinetA to return 0, got %d\n", i, ret);
84 if (invalid_parameters[i].todo_lasterror)
87 ok(GetLastError() == invalid_parameters[i].expected_lasterror,
88 "[%d] Expected GetLastError() to return %u, got %u\n",
89 i, invalid_parameters[i].expected_lasterror, GetLastError());
93 ok(GetLastError() == invalid_parameters[i].expected_lasterror,
94 "[%d] Expected GetLastError() to return %u, got %u\n",
95 i, invalid_parameters[i].expected_lasterror, GetLastError());
99 SetLastError(0xdeadbeef);
100 ret = SetupIterateCabinetA("", 0, NULL, NULL);
101 ok(!ret, "Expected SetupIterateCabinetA to return 0, got %d\n", ret);
102 ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
103 GetLastError() == ERROR_FILE_NOT_FOUND, /* Win9x/NT4/Win2k */
104 "Expected GetLastError() to return ERROR_NOT_ENOUGH_MEMORY, got %u\n",
107 SetLastError(0xdeadbeef);
108 ret = SetupIterateCabinetA("", 0, dummy_callbackA, NULL);
109 ok(!ret, "Expected SetupIterateCabinetA to return 0, got %d\n", ret);
110 ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
111 GetLastError() == ERROR_FILE_NOT_FOUND, /* Win9x/NT4/Win2k */
112 "Expected GetLastError() to return ERROR_NOT_ENOUGH_MEMORY, got %u\n",
120 test_invalid_parametersA();