wine.inf: We should not override existing associations.
[wine/hacks.git] / dlls / version / tests / install.c
blob310ef4c4505c88b847e65f0017975bee2e31de88
1 /*
2 * Copyright (C) 2005 Stefan Leichter
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <stdio.h>
22 #include "wine/test.h"
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "winver.h"
28 static void test_find_file(void)
30 DWORD ret;
31 UINT dwCur, dwOut ;
32 char appdir[MAX_PATH];
33 char curdir[MAX_PATH];
34 char filename[MAX_PATH];
35 char outBuf[MAX_PATH];
36 char windir[MAX_PATH];
38 memset(appdir, 0, MAX_PATH);
39 memset(windir, 0, MAX_PATH);
41 dwCur=MAX_PATH;
42 dwOut=MAX_PATH;
43 memset(curdir, 0, MAX_PATH);
44 memset(outBuf, 0, MAX_PATH);
45 ret = VerFindFileA(0, "regedit", "", "", curdir, &dwCur, outBuf, &dwOut);
46 switch(ret) {
47 case 0L:
48 ok(dwCur == 1, "Wrong length of buffer for current location: "
49 "got %d(%s) expected 1\n", dwCur, curdir);
50 ok(dwOut == 1, "Wrong length of buffer for the recommended installation location: "
51 "got %d(%s) expected 1\n", dwOut, outBuf);
52 break;
53 case VFF_BUFFTOOSMALL:
54 ok(dwCur == MAX_PATH, "Wrong length of buffer for current location: "
55 "got %d(%s) expected MAX_PATH\n", dwCur, curdir);
56 ok(dwOut == MAX_PATH, "Wrong length of buffer for the recommended installation location: "
57 "got %d(%s) expected MAX_PATH\n", dwOut, outBuf);
58 break;
59 default:
60 ok(0, "Got unexpected return value %lx\n", ret);
63 if(!GetWindowsDirectoryA(windir, MAX_PATH))
64 trace("GetWindowsDirectoryA failed\n");
65 else {
66 sprintf(appdir, "%s\\regedit.exe", windir);
67 if(INVALID_FILE_ATTRIBUTES == GetFileAttributesA(appdir))
68 trace("GetFileAttributesA(%s) failed\n", appdir);
69 else {
70 dwCur=MAX_PATH;
71 dwOut=MAX_PATH;
72 memset(curdir, 0, MAX_PATH);
73 memset(outBuf, 0, MAX_PATH);
74 ret = VerFindFileA(0, "regedit.exe", "", "", curdir, &dwCur, outBuf, &dwOut);
75 switch(ret) {
76 case VFF_CURNEDEST:
77 ok(dwCur == 1 + strlen(windir), "Wrong length of buffer for current location: "
78 "got %d(%s) expected %d\n", dwCur, curdir, lstrlenA(windir)+1);
79 ok(dwOut == 1, "Wrong length of buffer for the recommended installation location: "
80 "got %d(%s) expected 1\n", dwOut, outBuf);
81 break;
82 case VFF_BUFFTOOSMALL:
83 ok(dwCur == MAX_PATH, "Wrong length of buffer for current location: "
84 "got %d(%s) expected MAX_PATH\n", dwCur, curdir);
85 ok(dwOut == MAX_PATH, "Wrong length of buffer for the recommended installation location: "
86 "got %d(%s) expected MAX_PATH\n", dwOut, outBuf);
87 break;
88 default:
89 todo_wine ok(0, "Got unexpected return value %lx\n", ret);
92 dwCur=MAX_PATH;
93 dwOut=MAX_PATH;
94 memset(curdir, 0, MAX_PATH);
95 memset(outBuf, 0, MAX_PATH);
96 ret = VerFindFileA(0, "regedit.exe", NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
97 switch(ret) {
98 case VFF_CURNEDEST:
99 ok(dwCur == 1 + strlen(windir), "Wrong length of buffer for current location: "
100 "got %d(%s) expected %d\n", dwCur, curdir, lstrlenA(windir)+1);
101 ok(dwOut == 1, "Wrong length of buffer for the recommended installation location: "
102 "got %d(%s) expected 1\n", dwOut, outBuf);
103 break;
104 case VFF_BUFFTOOSMALL:
105 ok(dwCur == MAX_PATH, "Wrong length of buffer for current location: "
106 "got %d(%s) expected MAX_PATH\n", dwCur, curdir);
107 ok(dwOut == MAX_PATH, "Wrong length of buffer for the recommended installation location: "
108 "got %d(%s) expected MAX_PATH\n", dwOut, outBuf);
109 break;
110 default:
111 todo_wine ok(0, "Got unexpected return value %lx\n", ret);
115 if(!GetModuleFileNameA(NULL, filename, MAX_PATH) ||
116 !GetSystemDirectoryA(windir, MAX_PATH) ||
117 !GetTempPathA(MAX_PATH, appdir))
118 trace("GetModuleFileNameA, GetSystemDirectoryA or GetTempPathA failed\n");
119 else {
120 char *p = strrchr(filename, '\\');
121 if(p) {
122 *(p++) ='\0';
123 SetCurrentDirectoryA(filename);
124 memmove(filename, p, 1 + strlen(p));
127 dwCur=MAX_PATH;
128 dwOut=MAX_PATH;
129 memset(outBuf, 0, MAX_PATH);
130 memset(curdir, 0, MAX_PATH);
131 ret = VerFindFileA(0, filename, NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
132 switch(ret) {
133 case VFF_CURNEDEST:
134 ok(dwOut == 1, "Wrong length of buffer for the recommended installation location"
135 "got %d(%s) expected 1\n", dwOut, outBuf);
136 break;
137 case VFF_BUFFTOOSMALL:
138 ok(dwOut == MAX_PATH, "Wrong length of buffer for the recommended installation location"
139 "got %d(%s) expected MAX_PATH\n", dwOut, outBuf);
140 break;
141 default:
142 todo_wine ok(0, "Got unexpected return value %lx\n", ret);
145 dwCur=MAX_PATH;
146 dwOut=MAX_PATH;
147 memset(outBuf, 0, MAX_PATH);
148 memset(curdir, 0, MAX_PATH);
149 ret = VerFindFileA(VFFF_ISSHAREDFILE, filename, NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
150 todo_wine ok(VFF_CURNEDEST == ret, "Wrong return value got %lx expected VFF_CURNEDEST\n", ret);
151 ok(dwOut == 1 + strlen(windir), "Wrong length of buffer for current location: "
152 "got %d(%s) expected %d\n", dwOut, outBuf, lstrlenA(windir)+1);
154 dwCur=MAX_PATH;
155 dwOut=MAX_PATH;
156 memset(outBuf, 0, MAX_PATH);
157 memset(curdir, 0, MAX_PATH);
158 ret = VerFindFileA(0, filename, NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
159 todo_wine ok(VFF_CURNEDEST == ret, "Wrong return value got %lx expected VFF_CURNEDEST\n", ret);
160 ok(dwOut == 1 + strlen(appdir), "Wrong length of buffer for current location: "
161 "got %d(%s) expected %d\n", dwOut, outBuf, lstrlenA(appdir)+1);
165 START_TEST(install)
167 test_find_file();