- test cases for summary information
[wine/dcerpc.git] / dlls / msi / tests / suminfo.c
blobe51dae00c4c3e523e33adf2e6465b594fe7f3add
1 /*
2 * Copyright (C) 2005 Mike McCormack for CodeWeavers
4 * A test program for MSI database files.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define COBJMACROS
23 #include <stdio.h>
24 #include <windows.h>
25 #include <msi.h>
26 #include <msiquery.h>
28 #include "wine/test.h"
31 * The following are defined in Windows SDK's msidefs.h
32 * but that file doesn't exist in the msvc6 header set.
34 * Some are already defined in PropIdl.h - undefine them
36 #undef PID_DICTIONARY
37 #undef PID_CODEPAGE
38 #undef PID_SUBJECT
39 #undef PID_SECURITY
41 #define PID_DICTIONARY 0
42 #define PID_CODEPAGE 1
43 #define PID_TITLE 2
44 #define PID_SUBJECT 3
45 #define PID_AUTHOR 4
46 #define PID_KEYWORDS 5
47 #define PID_COMMENTS 6
48 #define PID_TEMPLATE 7
49 #define PID_LASTAUTHOR 8
50 #define PID_REVNUMBER 9
51 #define PID_EDITTINE 10
52 #define PID_LASTPRINTED 11
53 #define PID_CREATE_DTM 12
54 #define PID_LASTSAVE_DTM 13
55 #define PID_PAGECOUNT 14
56 #define PID_WORDCOUNT 15
57 #define PID_CHARCOUNT 16
58 #define PID_THUMBNAIL 17
59 #define PID_APPNAME 18
60 #define PID_SECURITY 19
61 #define PID_MSIVERSION PID_PAGECOUNT
62 #define PID_MSISOURCE PID_WORDCOUNT
63 #define PID_MSIRESTRICT PID_CHARCOUNT
65 START_TEST(suminfo)
67 const char *msifile = "winetest.msi";
68 MSIHANDLE hdb = 0, hsuminfo;
69 UINT r, count, type;
70 INT val;
71 FILETIME ft;
73 DeleteFile(msifile);
75 /* just MsiOpenDatabase should not create a file */
76 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
77 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
79 r = MsiGetSummaryInformation(hdb, NULL, 0, NULL);
80 ok(r == ERROR_INVALID_PARAMETER, "MsiGetSummaryInformation wrong error\n");
82 r = MsiGetSummaryInformation(hdb, NULL, 0, &hsuminfo);
83 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
85 r = MsiSummaryInfoGetPropertyCount(0, NULL);
86 ok(r == ERROR_INVALID_HANDLE, "getpropcount failed\n");
88 r = MsiSummaryInfoGetPropertyCount(hsuminfo, NULL);
89 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
91 count = -1;
92 r = MsiSummaryInfoGetPropertyCount(hsuminfo, &count);
93 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
94 ok(count == 0, "count should be zero\n");
96 r = MsiSummaryInfoGetProperty(hsuminfo, 0, NULL, NULL, NULL, 0, NULL);
97 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
99 type = -1;
100 r = MsiSummaryInfoGetProperty(hsuminfo, 0, &type, NULL, NULL, 0, NULL);
101 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
102 ok(type == 0, "wrong type\n");
104 type = -1;
105 val = 1234;
106 r = MsiSummaryInfoGetProperty(hsuminfo, 0, &type, &val, NULL, 0, NULL);
107 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
108 ok(type == 0, "wrong type\n");
109 ok(val == 1234, "wrong val\n");
111 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
112 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
114 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 1, NULL, "JungAh");
115 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
117 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 1, &ft, "Mike");
118 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
120 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "JungAh");
121 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
123 r = MsiCloseHandle(hsuminfo);
124 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
126 /* try again with the update count set */
127 r = MsiGetSummaryInformation(hdb, NULL, 1, &hsuminfo);
128 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
130 r = MsiSummaryInfoSetProperty(hsuminfo, 0, VT_LPSTR, 1, NULL, NULL);
131 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
133 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_LPSTR, 1, NULL, NULL);
134 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
136 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_I4, 0, NULL, "Mike");
137 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
139 r = MsiSummaryInfoSetProperty(hsuminfo, PID_AUTHOR, VT_I4, 0, NULL, "JungAh");
140 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
142 r = MsiSummaryInfoSetProperty(hsuminfo, PID_KEYWORDS, VT_I2, 0, NULL, "Mike");
143 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
145 r = MsiSummaryInfoSetProperty(hsuminfo, PID_COMMENTS, VT_FILETIME, 0, NULL, "JungAh");
146 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
148 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TEMPLATE, VT_I2, 0, NULL, "Mike");
149 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
151 r = MsiSummaryInfoSetProperty(hsuminfo, PID_LASTAUTHOR, VT_LPSTR, 0, NULL, NULL);
152 ok(r == ERROR_INVALID_PARAMETER, "MsiSummaryInfoSetProperty wrong error\n");
154 r = MsiSummaryInfoSetProperty(hsuminfo, PID_LASTSAVE_DTM, VT_FILETIME, 0, NULL, NULL);
155 ok(r == ERROR_INVALID_PARAMETER, "MsiSummaryInfoSetProperty wrong error\n");
157 r = MsiSummaryInfoSetProperty(hsuminfo, PID_LASTAUTHOR, VT_LPWSTR, 0, NULL, "h\0i\0\0");
158 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
160 r = MsiSummaryInfoSetProperty(hsuminfo, PID_REVNUMBER, VT_I4, 0, NULL, "Jungah");
161 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
163 r = MsiSummaryInfoSetProperty(hsuminfo, PID_PAGECOUNT, VT_LPSTR, 1, NULL, NULL);
164 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
166 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
167 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
169 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh");
170 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
172 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "Mike");
173 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
175 r = MsiCloseHandle(hsuminfo);
176 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
178 /* try again with a higher update count */
179 r = MsiGetSummaryInformation(hdb, NULL, 10, &hsuminfo);
180 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
182 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh");
183 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
185 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_LPSTR, 1, NULL, NULL);
186 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
188 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, NULL, NULL);
189 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
191 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "Mike");
192 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
194 r = MsiSummaryInfoSetProperty(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Mike");
195 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
197 r = MsiSummaryInfoPersist(hsuminfo);
198 ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist failed\n");
200 MsiDatabaseCommit(hdb);
202 r = MsiCloseHandle(hsuminfo);
203 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
205 r = MsiCloseHandle(hdb);
206 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
208 r = DeleteFile(msifile);
209 ok(r, "DeleteFile failed\n");