Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
bc7cb836
Commit
bc7cb836
authored
Feb 20, 2006
by
James Hawkins
Committed by
Alexandre Julliard
Feb 21, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advpack: Add tests for AddDelBackupEntry.
parent
7d8f9de8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
127 additions
and
0 deletions
+127
-0
files.c
dlls/advpack/tests/files.c
+127
-0
No files found.
dlls/advpack/tests/files.c
View file @
bc7cb836
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
/* function pointers */
/* function pointers */
HMODULE
hAdvPack
;
HMODULE
hAdvPack
;
static
HRESULT
(
WINAPI
*
pAddDelBackupEntry
)(
LPCSTR
,
LPCSTR
,
LPCSTR
,
DWORD
);
static
HRESULT
(
WINAPI
*
pExtractFiles
)(
LPCSTR
,
LPCSTR
,
DWORD
,
LPCSTR
,
LPVOID
,
DWORD
);
static
HRESULT
(
WINAPI
*
pExtractFiles
)(
LPCSTR
,
LPCSTR
,
DWORD
,
LPCSTR
,
LPVOID
,
DWORD
);
static
HRESULT
(
WINAPI
*
pAdvInstallFile
)(
HWND
,
LPCSTR
,
LPCSTR
,
LPCSTR
,
LPCSTR
,
DWORD
,
DWORD
);
static
HRESULT
(
WINAPI
*
pAdvInstallFile
)(
HWND
,
LPCSTR
,
LPCSTR
,
LPCSTR
,
LPCSTR
,
DWORD
,
DWORD
);
...
@@ -41,6 +42,7 @@ static void init_function_pointers(void)
...
@@ -41,6 +42,7 @@ static void init_function_pointers(void)
if
(
hAdvPack
)
if
(
hAdvPack
)
{
{
pAddDelBackupEntry
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"AddDelBackupEntry"
);
pExtractFiles
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"ExtractFiles"
);
pExtractFiles
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"ExtractFiles"
);
pAdvInstallFile
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"AdvInstallFile"
);
pAdvInstallFile
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"AdvInstallFile"
);
}
}
...
@@ -89,6 +91,130 @@ static void delete_test_files(void)
...
@@ -89,6 +91,130 @@ static void delete_test_files(void)
DeleteFileA
(
"extract.cab"
);
DeleteFileA
(
"extract.cab"
);
}
}
static
BOOL
check_ini_file_attr
(
LPSTR
filename
)
{
BOOL
ret
;
DWORD
expected
=
FILE_ATTRIBUTE_HIDDEN
|
FILE_ATTRIBUTE_READONLY
;
DWORD
attr
=
GetFileAttributesA
(
filename
);
ret
=
(
attr
&
expected
)
&&
(
attr
!=
INVALID_FILE_ATTRIBUTES
);
SetFileAttributesA
(
filename
,
FILE_ATTRIBUTE_NORMAL
);
return
ret
;
}
#define FIELD_LEN 16
static
BOOL
check_ini_contents
(
LPSTR
filename
,
BOOL
add
)
{
CHAR
field
[
FIELD_LEN
];
BOOL
ret
=
TRUE
,
match
;
GetPrivateProfileStringA
(
"backup"
,
"one"
,
NULL
,
field
,
FIELD_LEN
,
filename
);
match
=
!
lstrcmpA
(
field
,
"-1,0,0,0,0,0,-1"
);
if
((
add
&&
!
match
)
||
(
!
add
&&
match
))
ret
=
FALSE
;
GetPrivateProfileStringA
(
"backup"
,
"two"
,
NULL
,
field
,
FIELD_LEN
,
filename
);
if
(
lstrcmpA
(
field
,
"-1,0,0,0,0,0,-1"
))
ret
=
FALSE
;
GetPrivateProfileStringA
(
"backup"
,
"three"
,
NULL
,
field
,
FIELD_LEN
,
filename
);
match
=
!
lstrcmpA
(
field
,
"-1,0,0,0,0,0,-1"
);
if
((
add
&&
!
match
)
||
(
!
add
&&
match
))
ret
=
FALSE
;
return
ret
;
}
static
void
test_AddDelBackupEntry
()
{
HRESULT
res
;
CHAR
path
[
MAX_PATH
];
lstrcpyA
(
path
,
CURR_DIR
);
lstrcatA
(
path
,
"
\\
backup
\\
basename.INI"
);
/* native AddDelBackupEntry crashes if lpcszBaseName is NULL */
/* try a NULL file list */
res
=
pAddDelBackupEntry
(
NULL
,
"backup"
,
"basename"
,
AADBE_ADD_ENTRY
);
ok
(
res
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
res
);
ok
(
!
DeleteFileA
(
path
),
"Expected path to not exist
\n
"
);
lstrcpyA
(
path
,
CURR_DIR
);
lstrcatA
(
path
,
"
\\
backup
\\
.INI"
);
/* try an empty base name */
res
=
pAddDelBackupEntry
(
"one
\0
two
\0
three"
,
"backup"
,
""
,
AADBE_ADD_ENTRY
);
ok
(
res
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
res
);
ok
(
!
DeleteFileA
(
path
),
"Expected path to not exist
\n
"
);
lstrcpyA
(
path
,
CURR_DIR
);
lstrcatA
(
path
,
"
\\
basename.INI"
);
/* try an invalid flag */
res
=
pAddDelBackupEntry
(
"one
\0
two
\0
three"
,
NULL
,
"basename"
,
0
);
ok
(
res
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
res
);
ok
(
!
DeleteFileA
(
path
),
"Expected path to not exist
\n
"
);
lstrcpyA
(
path
,
"c:
\\
basename.INI"
);
/* create the INF file */
res
=
pAddDelBackupEntry
(
"one
\0
two
\0
three"
,
"c:
\\
"
,
"basename"
,
AADBE_ADD_ENTRY
);
ok
(
res
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
res
);
todo_wine
{
ok
(
check_ini_file_attr
(
path
),
"Expected ini file to be hidden
\n
"
);
ok
(
check_ini_contents
(
path
,
TRUE
),
"Expected ini contents to match
\n
"
);
ok
(
DeleteFileA
(
path
),
"Expected path to exist
\n
"
);
}
lstrcpyA
(
path
,
CURR_DIR
);
lstrcatA
(
path
,
"
\\
backup
\\
basename.INI"
);
/* try to create the INI file in a nonexistent directory */
RemoveDirectoryA
(
"backup"
);
res
=
pAddDelBackupEntry
(
"one
\0
two
\0
three"
,
"backup"
,
"basename"
,
AADBE_ADD_ENTRY
);
ok
(
res
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
res
);
ok
(
!
check_ini_file_attr
(
path
),
"Expected ini file to not be hidden
\n
"
);
ok
(
!
check_ini_contents
(
path
,
TRUE
),
"Expected ini contents to not match
\n
"
);
ok
(
!
DeleteFileA
(
path
),
"Expected path to not exist
\n
"
);
/* try an existent, relative backup directory */
CreateDirectoryA
(
"backup"
,
NULL
);
res
=
pAddDelBackupEntry
(
"one
\0
two
\0
three"
,
"backup"
,
"basename"
,
AADBE_ADD_ENTRY
);
ok
(
res
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
res
);
todo_wine
{
ok
(
check_ini_file_attr
(
path
),
"Expected ini file to be hidden
\n
"
);
ok
(
check_ini_contents
(
path
,
TRUE
),
"Expected ini contents to match
\n
"
);
ok
(
DeleteFileA
(
path
),
"Expected path to exist
\n
"
);
}
RemoveDirectoryA
(
"backup"
);
lstrcpyA
(
path
,
"c:
\\
windows
\\
basename.INI"
);
/* try a NULL backup dir, INI is created in c:\windows */
res
=
pAddDelBackupEntry
(
"one
\0
two
\0
three"
,
NULL
,
"basename"
,
AADBE_ADD_ENTRY
);
ok
(
res
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
res
);
todo_wine
{
ok
(
check_ini_contents
(
path
,
TRUE
),
"Expected ini contents to match
\n
"
);
}
/* remove the entries with AADBE_DEL_ENTRY */
SetFileAttributesA
(
path
,
FILE_ATTRIBUTE_NORMAL
);
res
=
pAddDelBackupEntry
(
"one
\0
three"
,
NULL
,
"basename"
,
AADBE_DEL_ENTRY
);
SetFileAttributesA
(
path
,
FILE_ATTRIBUTE_NORMAL
);
ok
(
res
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
res
);
todo_wine
{
ok
(
check_ini_contents
(
path
,
FALSE
),
"Expected ini contents to match
\n
"
);
ok
(
DeleteFileA
(
path
),
"Expected path to exist
\n
"
);
}
}
/* the FCI callbacks */
/* the FCI callbacks */
static
void
*
mem_alloc
(
ULONG
cb
)
static
void
*
mem_alloc
(
ULONG
cb
)
...
@@ -428,6 +554,7 @@ START_TEST(files)
...
@@ -428,6 +554,7 @@ START_TEST(files)
create_test_files
();
create_test_files
();
create_cab_file
();
create_cab_file
();
test_AddDelBackupEntry
();
test_ExtractFiles
();
test_ExtractFiles
();
test_AdvInstallFile
();
test_AdvInstallFile
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment