Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
93089217
Commit
93089217
authored
May 02, 2014
by
Akihiro Sagawa
Committed by
Alexandre Julliard
May 02, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvfw32/tests: Add tests for drawdib.
parent
b6ef7274
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
168 additions
and
1 deletion
+168
-1
Makefile.in
dlls/msvfw32/tests/Makefile.in
+2
-1
drawdib.c
dlls/msvfw32/tests/drawdib.c
+166
-0
No files found.
dlls/msvfw32/tests/Makefile.in
View file @
93089217
TESTDLL
=
msvfw32.dll
IMPORTS
=
msvfw32
IMPORTS
=
msvfw32
advapi32 gdi32
C_SRCS
=
\
drawdib.c
\
msvfw.c
dlls/msvfw32/tests/drawdib.c
0 → 100644
View file @
93089217
/*
* Copyright 2014 Akihiro Sagawa
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <vfw.h>
#include <wincrypt.h>
#include <stdlib.h>
#include <string.h>
#include "wine/test.h"
#define WIDTH 16
#define HEIGHT 12
static
HCRYPTPROV
crypt_prov
;
static
inline
DWORD
get_stride
(
const
BITMAPINFO
*
bmi
)
{
return
((
bmi
->
bmiHeader
.
biBitCount
*
bmi
->
bmiHeader
.
biWidth
+
31
)
>>
3
)
&
~
3
;
}
static
inline
DWORD
get_dib_size
(
const
BITMAPINFO
*
bmi
)
{
return
get_stride
(
bmi
)
*
abs
(
bmi
->
bmiHeader
.
biHeight
);
}
static
char
*
hash_dib
(
const
BITMAPINFO
*
bmi
,
const
void
*
bits
)
{
DWORD
dib_size
=
get_dib_size
(
bmi
);
HCRYPTHASH
hash
;
char
*
buf
;
BYTE
hash_buf
[
20
];
DWORD
hash_size
=
sizeof
(
hash_buf
);
int
i
;
static
const
char
*
hex
=
"0123456789abcdef"
;
if
(
!
crypt_prov
)
return
NULL
;
if
(
!
CryptCreateHash
(
crypt_prov
,
CALG_SHA1
,
0
,
0
,
&
hash
))
return
NULL
;
CryptHashData
(
hash
,
bits
,
dib_size
,
0
);
CryptGetHashParam
(
hash
,
HP_HASHVAL
,
NULL
,
&
hash_size
,
0
);
if
(
hash_size
!=
sizeof
(
hash_buf
))
return
NULL
;
CryptGetHashParam
(
hash
,
HP_HASHVAL
,
hash_buf
,
&
hash_size
,
0
);
CryptDestroyHash
(
hash
);
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
hash_size
*
2
+
1
);
for
(
i
=
0
;
i
<
hash_size
;
i
++
)
{
buf
[
i
*
2
]
=
hex
[
hash_buf
[
i
]
>>
4
];
buf
[
i
*
2
+
1
]
=
hex
[
hash_buf
[
i
]
&
0xf
];
}
buf
[
i
*
2
]
=
'\0'
;
return
buf
;
}
static
void
init_bmi
(
BITMAPINFO
*
bmi
,
LONG
width
,
LONG
height
,
DWORD
size
)
{
memset
(
bmi
,
0
,
sizeof
(
*
bmi
));
bmi
->
bmiHeader
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
bmi
->
bmiHeader
.
biWidth
=
width
;
bmi
->
bmiHeader
.
biHeight
=
height
;
bmi
->
bmiHeader
.
biPlanes
=
1
;
bmi
->
bmiHeader
.
biBitCount
=
32
;
bmi
->
bmiHeader
.
biCompression
=
BI_RGB
;
bmi
->
bmiHeader
.
biSizeImage
=
size
;
}
static
void
test_DrawDib_sizeimage
(
void
)
{
const
struct
{
LONG
width
,
height
;
DWORD
size
;
char
hash
[
41
];
}
test_data
[]
=
{
/* [0] correct size */
{
WIDTH
,
HEIGHT
,
WIDTH
*
HEIGHT
*
sizeof
(
RGBQUAD
),
"bc943d5ab024b8b0118d0a80aa283055d39942b8"
},
/* [1] zero size */
{
WIDTH
,
HEIGHT
,
0
,
"bc943d5ab024b8b0118d0a80aa283055d39942b8"
},
};
HDC
hdc
;
DWORD
src_dib_size
,
dst_dib_size
;
BOOL
r
;
HBITMAP
dib
;
BITMAPINFO
src_info
,
dst_info
;
RGBQUAD
*
src_bits
=
NULL
,
*
dst_bits
;
HDRAWDIB
hdd
;
unsigned
int
i
;
hdc
=
CreateCompatibleDC
(
NULL
);
init_bmi
(
&
dst_info
,
WIDTH
,
HEIGHT
,
0
);
dib
=
CreateDIBSection
(
NULL
,
&
dst_info
,
DIB_RGB_COLORS
,
(
void
**
)
&
dst_bits
,
NULL
,
0
);
dst_dib_size
=
get_dib_size
(
&
dst_info
);
ok
(
dib
!=
NULL
,
"CreateDIBSection failed
\n
"
);
SelectObject
(
hdc
,
dib
);
init_bmi
(
&
src_info
,
WIDTH
,
HEIGHT
,
0
);
src_dib_size
=
get_dib_size
(
&
src_info
);
src_bits
=
HeapAlloc
(
GetProcessHeap
(),
0
,
src_dib_size
);
ok
(
src_bits
!=
NULL
,
"Can't allocate memory
\n
"
);
memset
(
src_bits
,
0x88
,
src_dib_size
);
hdd
=
DrawDibOpen
();
ok
(
hdd
!=
NULL
,
"DrawDibOpen failed
\n
"
);
for
(
i
=
0
;
i
<
sizeof
(
test_data
)
/
sizeof
(
test_data
[
0
]);
i
++
)
{
char
*
hash
;
memset
(
dst_bits
,
0xff
,
dst_dib_size
);
init_bmi
(
&
src_info
,
test_data
[
i
].
width
,
test_data
[
i
].
height
,
test_data
[
i
].
size
);
r
=
DrawDibDraw
(
hdd
,
hdc
,
0
,
0
,
-
1
,
-
1
,
&
src_info
.
bmiHeader
,
src_bits
,
0
,
0
,
test_data
[
i
].
width
,
test_data
[
i
].
height
,
0
);
if
(
test_data
[
i
].
hash
[
0
])
ok
(
r
,
"[%u] DrawDibDraw failed, expected success
\n
"
,
i
);
else
ok
(
!
r
,
"[%u] DrawDibDraw succeeded, expected failed
\n
"
,
i
);
if
(
!
r
||
!
test_data
[
i
].
hash
[
0
])
continue
;
hash
=
hash_dib
(
&
dst_info
,
dst_bits
);
if
(
!
hash
)
{
win_skip
(
"This platform doesn't support SHA-1 hash
\n
"
);
continue
;
}
ok
(
strcmp
(
hash
,
test_data
[
i
].
hash
)
==
0
,
"[%u] got %s, expected %s
\n
"
,
i
,
hash
,
test_data
[
i
].
hash
);
HeapFree
(
GetProcessHeap
(),
0
,
hash
);
}
r
=
DrawDibClose
(
hdd
);
ok
(
r
,
"DrawDibClose failed
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
src_bits
);
DeleteDC
(
hdc
);
}
START_TEST
(
drawdib
)
{
CryptAcquireContextW
(
&
crypt_prov
,
NULL
,
NULL
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
);
test_DrawDib_sizeimage
();
CryptReleaseContext
(
crypt_prov
,
0
);
}
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