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
3be7ec34
Commit
3be7ec34
authored
Oct 02, 2009
by
Wilfried Pasquazzo
Committed by
Alexandre Julliard
Oct 05, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32/tests: DrawState: New test case for correct drawing of icons.
parent
c81d1e78
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
125 additions
and
0 deletions
+125
-0
cursoricon.c
dlls/user32/tests/cursoricon.c
+125
-0
No files found.
dlls/user32/tests/cursoricon.c
View file @
3be7ec34
...
@@ -1229,6 +1229,130 @@ cleanup:
...
@@ -1229,6 +1229,130 @@ cleanup:
DeleteDC
(
hdcDst
);
DeleteDC
(
hdcDst
);
}
}
static
void
check_DrawState_Size
(
HDC
hdc
,
BOOL
maskvalue
,
UINT32
color
,
int
bpp
,
HBRUSH
hbr
,
UINT
flags
,
int
line
)
{
COLORREF
result
,
background
;
BOOL
passed
[
2
];
HICON
hicon
=
create_test_icon
(
hdc
,
1
,
1
,
bpp
,
maskvalue
,
&
color
,
sizeof
(
color
));
background
=
0x00FFFFFF
;
/* Set color of the 2 pixels that will be checked afterwards */
SetPixelV
(
hdc
,
0
,
0
,
background
);
SetPixelV
(
hdc
,
2
,
2
,
background
);
/* Let DrawState calculate the size of the icon (it's 1x1) */
DrawState
(
hdc
,
hbr
,
NULL
,
(
LPARAM
)
hicon
,
0
,
1
,
1
,
0
,
0
,
(
DST_ICON
|
flags
));
result
=
GetPixel
(
hdc
,
0
,
0
);
passed
[
0
]
=
color_match
(
result
,
background
);
result
=
GetPixel
(
hdc
,
2
,
2
);
passed
[
0
]
=
passed
[
0
]
&
color_match
(
result
,
background
);
/* Check if manually specifying the icon size DOESN'T work */
/* IMPORTANT: For Icons, DrawState wants the size of the source image, not the
* size in which it should be ultimately drawn. Therefore giving
* width/height 2x2 if the icon is only 1x1 pixels in size should
* result in drawing it with size 1x1. The size parameters must be
* ignored if a Icon has to be drawn! */
DrawState
(
hdc
,
hbr
,
NULL
,
(
LPARAM
)
hicon
,
0
,
1
,
1
,
2
,
2
,
(
DST_ICON
|
flags
));
result
=
GetPixel
(
hdc
,
0
,
0
);
passed
[
1
]
=
color_match
(
result
,
background
);
result
=
GetPixel
(
hdc
,
2
,
2
);
passed
[
1
]
=
passed
[
0
]
&
color_match
(
result
,
background
);
if
(
!
passed
[
0
]
&&!
passed
[
1
])
ok
(
passed
[
1
],
"DrawState failed to draw a 1x1 Icon in the correct size, independent of the "
"width and height settings passed to it, for Icon with: Overlaying Mask %d on "
"Color %06X with flags %08X. Line %d
\n
"
,
maskvalue
,
color
,
(
DST_ICON
|
flags
),
line
);
else
if
(
!
passed
[
1
])
ok
(
passed
[
1
],
"DrawState failed to draw a 1x1 Icon in the correct size, if the width and height "
"parameters passed to it are bigger than the real Icon size, for Icon with: Overlaying "
"Mask %d on Color %06X with flags %08X. Line %d
\n
"
,
maskvalue
,
color
,
(
DST_ICON
|
flags
),
line
);
else
ok
(
passed
[
0
],
"DrawState failed to draw a 1x1 Icon in the correct size, if the width and height "
"parameters passed to it are 0, for Icon with: Overlaying Mask %d on "
"Color %06X with flags %08X. Line %d
\n
"
,
maskvalue
,
color
,
(
DST_ICON
|
flags
),
line
);
}
static
void
check_DrawState_Color
(
HDC
hdc
,
BOOL
maskvalue
,
UINT32
color
,
int
bpp
,
HBRUSH
hbr
,
UINT
flags
,
COLORREF
background
,
COLORREF
modern_expected
,
COLORREF
legacy_expected
,
int
line
)
{
COLORREF
result
;
HICON
hicon
=
create_test_icon
(
hdc
,
1
,
1
,
bpp
,
maskvalue
,
&
color
,
sizeof
(
color
));
if
(
!
hicon
)
return
;
/* Set color of the pixel that will be checked afterwards */
SetPixelV
(
hdc
,
1
,
1
,
background
);
DrawState
(
hdc
,
hbr
,
NULL
,
(
LPARAM
)
hicon
,
0
,
1
,
1
,
0
,
0
,
(
DST_ICON
|
flags
));
/* Check the color of the pixel is correct */
result
=
GetPixel
(
hdc
,
1
,
1
);
ok
(
color_match
(
result
,
modern_expected
)
||
/* Windows 2000 and up */
broken
(
color_match
(
result
,
legacy_expected
)),
/* Windows NT 4.0, 9X and below */
"DrawState drawing Icon with Overlaying Mask %d on Color %06X with flags %08X. "
"Expected a close match to %06X (modern) or %06X (legacy). Got %06X from line %d
\n
"
,
maskvalue
,
color
,
(
DST_ICON
|
flags
),
modern_expected
,
legacy_expected
,
result
,
line
);
}
static
void
test_DrawState
(
void
)
{
BITMAPINFO
bitmapInfo
;
HDC
hdcDst
=
NULL
;
HBITMAP
bmpDst
=
NULL
;
HBITMAP
bmpOld
=
NULL
;
UINT32
bits
=
0
;
hdcDst
=
CreateCompatibleDC
(
0
);
ok
(
hdcDst
!=
0
,
"CreateCompatibleDC(0) failed to return a valid DC
\n
"
);
if
(
!
hdcDst
)
return
;
if
(
GetDeviceCaps
(
hdcDst
,
BITSPIXEL
)
<=
8
)
{
skip
(
"Windows will distort DrawIconEx colors at 8-bpp and less due to palletizing.
\n
"
);
goto
cleanup
;
}
memset
(
&
bitmapInfo
,
0
,
sizeof
(
bitmapInfo
));
bitmapInfo
.
bmiHeader
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
bitmapInfo
.
bmiHeader
.
biWidth
=
3
;
bitmapInfo
.
bmiHeader
.
biHeight
=
3
;
bitmapInfo
.
bmiHeader
.
biBitCount
=
32
;
bitmapInfo
.
bmiHeader
.
biPlanes
=
1
;
bitmapInfo
.
bmiHeader
.
biCompression
=
BI_RGB
;
bitmapInfo
.
bmiHeader
.
biSizeImage
=
sizeof
(
UINT32
);
bmpDst
=
CreateDIBSection
(
hdcDst
,
&
bitmapInfo
,
DIB_RGB_COLORS
,
(
void
**
)
&
bits
,
NULL
,
0
);
ok
(
bmpDst
&&
bits
,
"CreateDIBSection failed to return a valid bitmap and buffer
\n
"
);
if
(
!
bmpDst
||
!
bits
)
goto
cleanup
;
bmpOld
=
SelectObject
(
hdcDst
,
bmpDst
);
/* potential flags to test with DrawState are: */
/* DSS_DISABLED embosses the icon */
/* DSS_MONO draw Icon using a brush as parameter 5 */
/* DSS_NORMAL draw Icon without any modifications */
/* DSS_UNION draw the Icon dithered */
todo_wine
check_DrawState_Size
(
hdcDst
,
FALSE
,
0x00A0B0C0
,
32
,
0
,
DSS_NORMAL
,
__LINE__
);
check_DrawState_Color
(
hdcDst
,
FALSE
,
0x00A0B0C0
,
32
,
0
,
DSS_NORMAL
,
0x00FFFFFF
,
0x00C0B0A0
,
0x00C0B0A0
,
__LINE__
);
cleanup:
if
(
bmpOld
)
SelectObject
(
hdcDst
,
bmpOld
);
if
(
bmpDst
)
DeleteObject
(
bmpDst
);
if
(
hdcDst
)
DeleteDC
(
hdcDst
);
}
static
void
test_DestroyCursor
(
void
)
static
void
test_DestroyCursor
(
void
)
{
{
static
const
BYTE
bmp_bits
[
4096
];
static
const
BYTE
bmp_bits
[
4096
];
...
@@ -1338,6 +1462,7 @@ START_TEST(cursoricon)
...
@@ -1338,6 +1462,7 @@ START_TEST(cursoricon)
test_CreateIconFromResource
();
test_CreateIconFromResource
();
test_DrawIcon
();
test_DrawIcon
();
test_DrawIconEx
();
test_DrawIconEx
();
test_DrawState
();
test_DestroyCursor
();
test_DestroyCursor
();
do_parent
();
do_parent
();
test_child_process
();
test_child_process
();
...
...
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