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
0aebe831
Commit
0aebe831
authored
Apr 05, 2011
by
Huw Davies
Committed by
Alexandre Julliard
Apr 05, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32/tests: Start of a framework for writing dib driver tests.
parent
9bf247d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
1 deletion
+154
-1
Makefile.in
dlls/gdi32/tests/Makefile.in
+2
-1
dib.c
dlls/gdi32/tests/dib.c
+152
-0
No files found.
dlls/gdi32/tests/Makefile.in
View file @
0aebe831
TESTDLL
=
gdi32.dll
IMPORTS
=
user32 gdi32
IMPORTS
=
user32 gdi32
advapi32
C_SRCS
=
\
bitmap.c
\
brush.c
\
clipping.c
\
dc.c
\
dib.c
\
font.c
\
gdiobj.c
\
generated.c
\
...
...
dlls/gdi32/tests/dib.c
0 → 100644
View file @
0aebe831
/*
* DIB driver tests.
*
* Copyright 2011 Huw Davies
*
* 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
*/
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wincrypt.h"
#include "wine/test.h"
static
HCRYPTPROV
crypt_prov
;
static
const
char
*
sha1_graphics_a8r8g8b8
[]
=
{
"a3cadd34d95d3d5cc23344f69aab1c2e55935fcf"
,
NULL
};
static
inline
DWORD
get_stride
(
BITMAPINFO
*
bmi
)
{
return
((
bmi
->
bmiHeader
.
biBitCount
*
bmi
->
bmiHeader
.
biWidth
+
31
)
>>
3
)
&
~
3
;
}
static
inline
DWORD
get_dib_size
(
BITMAPINFO
*
bmi
)
{
return
get_stride
(
bmi
)
*
abs
(
bmi
->
bmiHeader
.
biHeight
);
}
static
char
*
hash_dib
(
BITMAPINFO
*
bmi
,
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
compare_hash
(
BITMAPINFO
*
bmi
,
BYTE
*
bits
,
const
char
***
sha1
,
const
char
*
info
)
{
char
*
hash
=
hash_dib
(
bmi
,
bits
);
if
(
!
hash
)
{
skip
(
"SHA1 hashing unavailable on this platform
\n
"
);
return
;
}
if
(
**
sha1
)
{
ok
(
!
strcmp
(
hash
,
**
sha1
),
"%d: %s: expected hash %s got %s
\n
"
,
bmi
->
bmiHeader
.
biBitCount
,
info
,
**
sha1
,
hash
);
(
*
sha1
)
++
;
}
else
trace
(
"
\"
%s
\"
,
\n
"
,
hash
);
HeapFree
(
GetProcessHeap
(),
0
,
hash
);
}
static
void
draw_graphics
(
HDC
hdc
,
BITMAPINFO
*
bmi
,
BYTE
*
bits
,
const
char
***
sha1
)
{
DWORD
dib_size
=
get_dib_size
(
bmi
);
memset
(
bits
,
0xcc
,
dib_size
);
compare_hash
(
bmi
,
bits
,
sha1
,
"empty"
);
}
static
void
test_simple_graphics
(
void
)
{
char
bmibuf
[
sizeof
(
BITMAPINFO
)
+
256
*
sizeof
(
RGBQUAD
)];
BITMAPINFO
*
bmi
=
(
BITMAPINFO
*
)
bmibuf
;
HDC
mem_dc
;
BYTE
*
bits
;
HBITMAP
dib
,
orig_bm
;
const
char
**
sha1
;
/* a8r8g8b8 */
trace
(
"8888
\n
"
);
memset
(
bmi
,
0
,
sizeof
(
bmibuf
));
bmi
->
bmiHeader
.
biSize
=
sizeof
(
bmi
->
bmiHeader
);
bmi
->
bmiHeader
.
biHeight
=
512
;
bmi
->
bmiHeader
.
biWidth
=
512
;
bmi
->
bmiHeader
.
biBitCount
=
32
;
bmi
->
bmiHeader
.
biPlanes
=
1
;
bmi
->
bmiHeader
.
biCompression
=
BI_RGB
;
dib
=
CreateDIBSection
(
0
,
bmi
,
DIB_RGB_COLORS
,
(
void
**
)
&
bits
,
NULL
,
0
);
ok
(
dib
!=
NULL
,
"ret NULL
\n
"
);
mem_dc
=
CreateCompatibleDC
(
NULL
);
orig_bm
=
SelectObject
(
mem_dc
,
dib
);
sha1
=
sha1_graphics_a8r8g8b8
;
draw_graphics
(
mem_dc
,
bmi
,
bits
,
&
sha1
);
SelectObject
(
mem_dc
,
orig_bm
);
DeleteObject
(
dib
);
DeleteDC
(
mem_dc
);
}
START_TEST
(
dib
)
{
CryptAcquireContextW
(
&
crypt_prov
,
NULL
,
NULL
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
);
test_simple_graphics
();
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