Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
bc7cb836
Commit
bc7cb836
authored
19 years ago
by
James Hawkins
Committed by
Alexandre Julliard
19 years ago
Browse files
Options
Downloads
Patches
Plain Diff
advpack: Add tests for AddDelBackupEntry.
parent
7d8f9de8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/advpack/tests/files.c
+127
-0
127 additions, 0 deletions
dlls/advpack/tests/files.c
with
127 additions
and
0 deletions
dlls/advpack/tests/files.c
+
127
−
0
View file @
bc7cb836
...
...
@@ -30,6 +30,7 @@
/* function pointers */
HMODULE
hAdvPack
;
static
HRESULT
(
WINAPI
*
pAddDelBackupEntry
)(
LPCSTR
,
LPCSTR
,
LPCSTR
,
DWORD
);
static
HRESULT
(
WINAPI
*
pExtractFiles
)(
LPCSTR
,
LPCSTR
,
DWORD
,
LPCSTR
,
LPVOID
,
DWORD
);
static
HRESULT
(
WINAPI
*
pAdvInstallFile
)(
HWND
,
LPCSTR
,
LPCSTR
,
LPCSTR
,
LPCSTR
,
DWORD
,
DWORD
);
...
...
@@ -41,6 +42,7 @@ static void init_function_pointers(void)
if
(
hAdvPack
)
{
pAddDelBackupEntry
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"AddDelBackupEntry"
);
pExtractFiles
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"ExtractFiles"
);
pAdvInstallFile
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"AdvInstallFile"
);
}
...
...
@@ -89,6 +91,130 @@ static void delete_test_files(void)
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 */
static
void
*
mem_alloc
(
ULONG
cb
)
...
...
@@ -428,6 +554,7 @@ START_TEST(files)
create_test_files
();
create_cab_file
();
test_AddDelBackupEntry
();
test_ExtractFiles
();
test_AdvInstallFile
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment