user32: DrawText handling of 0 counts with string, empty strings and -1 counts with empty string and NULL strings.
This commit is contained in:
parent
8b9ebc30c9
commit
48ad706c08
|
@ -27,6 +27,9 @@
|
|||
#include "winuser.h"
|
||||
#include "winerror.h"
|
||||
|
||||
#define MODIFIED(rect) (rect.left = 10 && rect.right != 100 && rect.top == 10 && rect.bottom != 100)
|
||||
#define SAME(rect) (rect.left = 10 && rect.right == 100 && rect.top == 10 && rect.bottom == 100)
|
||||
#define EMPTY(rect) (rect.left == rect.right && rect.bottom == rect.top)
|
||||
|
||||
static void test_DrawTextCalcRect(void)
|
||||
{
|
||||
|
@ -40,9 +43,11 @@ static void test_DrawTextCalcRect(void)
|
|||
's','t','r','i','n','g','\0'};
|
||||
static CHAR emptystring[] = "";
|
||||
static WCHAR emptystringW[] = { 0 };
|
||||
INT textlen, textheight;
|
||||
INT textlen, textheight, heightcheck;
|
||||
RECT rect = { 0, 0, 100, 0 };
|
||||
BOOL ret;
|
||||
DRAWTEXTPARAMS dtp;
|
||||
BOOL conform_xp = TRUE;
|
||||
|
||||
/* Initialization */
|
||||
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
|
||||
|
@ -105,63 +110,426 @@ static void test_DrawTextCalcRect(void)
|
|||
rect.bottom);
|
||||
|
||||
/* empty or null text should in some cases calc an empty rectangle */
|
||||
/* note: testing the function's return value is useless, it differs
|
||||
* ( 0 or 1) on every Windows version I tried */
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextExA(hdc, text, 0, &rect, DT_CALCRECT, NULL );
|
||||
ok( !(rect.left == rect.right && rect.bottom == rect.top),
|
||||
heightcheck = textheight = DrawTextExA(hdc, text, 0, &rect, DT_CALCRECT, NULL );
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (textheight != 0) /* Windows 98 */
|
||||
{
|
||||
win_skip("XP conformity failed, skipping XP tests. Probibly win9x\n");
|
||||
conform_xp = FALSE;
|
||||
}
|
||||
else
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextA(hdc, text, 0, &rect, DT_CALCRECT);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
SetLastError( 0);
|
||||
textheight = DrawTextExA(hdc, emptystring, -1, &rect, DT_CALCRECT, NULL );
|
||||
ok( (rect.left == rect.right && rect.bottom == rect.top),
|
||||
heightcheck = textheight = DrawTextExA(hdc, emptystring, -1, &rect, DT_CALCRECT, NULL );
|
||||
ok( EMPTY(rect),
|
||||
"rectangle should be empty got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextA(hdc, emptystring, -1, &rect, DT_CALCRECT);
|
||||
ok( EMPTY(rect),
|
||||
"rectangle should be empty got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
SetLastError( 0);
|
||||
textheight = DrawTextExA(hdc, NULL, -1, &rect, DT_CALCRECT, NULL );
|
||||
ok( (rect.left == rect.right && rect.bottom == rect.top),
|
||||
"rectangle should be empty got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
||||
heightcheck = textheight = DrawTextExA(hdc, NULL, -1, &rect, DT_CALCRECT, NULL );
|
||||
ok( EMPTY(rect) || !MODIFIED(rect),
|
||||
"rectangle should be empty or not modified got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (!textheight) /* Windows NT 4 */
|
||||
{
|
||||
if (conform_xp)
|
||||
win_skip("XP conformity failed, skipping XP tests. Probibly winNT\n");
|
||||
conform_xp = FALSE;
|
||||
}
|
||||
else
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextExA(hdc, NULL, 0, &rect, DT_CALCRECT, NULL );
|
||||
ok( !(rect.left == rect.right && rect.bottom == rect.top),
|
||||
textheight = DrawTextA(hdc, NULL, -1, &rect, DT_CALCRECT);
|
||||
ok( EMPTY(rect) || !MODIFIED(rect),
|
||||
"rectangle should be empty or NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
heightcheck = textheight = DrawTextExA(hdc, NULL, 0, &rect, DT_CALCRECT, NULL );
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextA(hdc, NULL, 0, &rect, DT_CALCRECT);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
/* DT_SINGLELINE tests */
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
heightcheck = textheight = DrawTextExA(hdc, text, 0, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextA(hdc, text, 0, &rect, DT_CALCRECT|DT_SINGLELINE);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
SetLastError( 0);
|
||||
heightcheck = textheight = DrawTextExA(hdc, emptystring, -1, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
||||
ok( !EMPTY(rect) && MODIFIED(rect),
|
||||
"rectangle should be modified got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextA(hdc, emptystring, -1, &rect, DT_CALCRECT|DT_SINGLELINE);
|
||||
ok( !EMPTY(rect) && MODIFIED (rect),
|
||||
"rectangle should be modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
SetLastError( 0);
|
||||
heightcheck = textheight = DrawTextExA(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
||||
ok( (!EMPTY(rect) && MODIFIED(rect)) || !MODIFIED(rect),
|
||||
"rectangle should be modified got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextA(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE);
|
||||
ok( (!EMPTY(rect) && MODIFIED(rect)) || !MODIFIED(rect),
|
||||
"rectangle should be modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
heightcheck = textheight = DrawTextExA(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextA(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
/* further tests with 0 count, NULL and empty strings */
|
||||
heightcheck = textheight = DrawTextA(hdc, text, 0, &rect, 0);
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextA\n");
|
||||
textheight = DrawTextExA(hdc, text, 0, &rect, 0, NULL );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
heightcheck = textheight = DrawTextA(hdc, emptystring, 0, &rect, 0);
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextA\n");
|
||||
textheight = DrawTextExA(hdc, emptystring, 0, &rect, 0, NULL );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
heightcheck = textheight = DrawTextA(hdc, NULL, 0, &rect, 0);
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextA\n");
|
||||
textheight = DrawTextExA(hdc, NULL, 0, &rect, 0, NULL );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
heightcheck = textheight = DrawTextA(hdc, emptystring, -1, &rect, 0);
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
|
||||
textheight = DrawTextExA(hdc, emptystring, -1, &rect, 0, NULL );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
heightcheck = textheight = DrawTextA(hdc, NULL, -1, &rect, 0);
|
||||
if (conform_xp)
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
|
||||
textheight = DrawTextExA(hdc, NULL, -1, &rect, 0, NULL );
|
||||
if (conform_xp)
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
heightcheck = textheight = DrawTextA(hdc, NULL, 10, &rect, 0);
|
||||
ok(textheight==0,"Got textheight from DrawTextA\n");
|
||||
textheight = DrawTextExA(hdc, NULL, 10, &rect, 0, NULL );
|
||||
ok(textheight==0,"Got textheight from DrawTextA\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
|
||||
/* invalid dtp size test */
|
||||
dtp.cbSize = -1; /* Invalid */
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExA(hdc, text, 0, &rect, 0, &dtp);
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExA(hdc, emptystring, 0, &rect, 0, &dtp);
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExA(hdc, NULL, 0, &rect, 0, &dtp);
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExA(hdc, emptystring, -1, &rect, 0, &dtp);
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExA(hdc, NULL, -1, &rect, 0, &dtp);
|
||||
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
|
||||
/* Wide char versions */
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
SetLastError( 0);
|
||||
textheight = DrawTextExW(hdc, textW, 0, &rect, DT_CALCRECT, NULL );
|
||||
heightcheck = textheight = DrawTextExW(hdc, textW, 0, &rect, DT_CALCRECT, NULL );
|
||||
if( GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) {
|
||||
ok( !(rect.left == rect.right && rect.bottom == rect.top),
|
||||
"rectangle should NOT be empty got %d,%d-%d,%d\n",
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextExW(hdc, emptystringW, -1, &rect, DT_CALCRECT, NULL );
|
||||
ok( (rect.left == rect.right && rect.bottom == rect.top),
|
||||
textheight = DrawTextW(hdc, textW, 0, &rect, DT_CALCRECT);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
heightcheck = textheight = DrawTextExW(hdc, emptystringW, -1, &rect, DT_CALCRECT, NULL );
|
||||
ok( EMPTY(rect),
|
||||
"rectangle should be empty got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (0) {
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
/* Crashes on NT4 */
|
||||
textheight = DrawTextExW(hdc, NULL, -1, &rect, DT_CALCRECT, NULL );
|
||||
ok( !(rect.left == rect.right && rect.bottom == rect.top),
|
||||
"rectangle should NOT be empty got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
}
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextExW(hdc, NULL, 0, &rect, DT_CALCRECT, NULL );
|
||||
ok( !(rect.left == rect.right && rect.bottom == rect.top),
|
||||
"rectangle should NOT be empty got %d,%d-%d,%d\n",
|
||||
textheight = DrawTextW(hdc, emptystringW, -1, &rect, DT_CALCRECT);
|
||||
ok( EMPTY(rect),
|
||||
"rectangle should be empty got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
heightcheck = textheight = DrawTextExW(hdc, NULL, 0, &rect, DT_CALCRECT, NULL );
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (textheight) /* windows 2000 */
|
||||
{
|
||||
if (conform_xp)
|
||||
win_skip("XP conformity failed, skipping XP tests. probibly win 2000\n");
|
||||
conform_xp = FALSE;
|
||||
}
|
||||
else
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextW(hdc, NULL, 0, &rect, DT_CALCRECT);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
if (conform_xp) {
|
||||
/* Crashes on NT4 */
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
heightcheck = textheight = DrawTextExW(hdc, NULL, -1, &rect, DT_CALCRECT, NULL );
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextW(hdc, NULL, -1, &rect, DT_CALCRECT);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight==0,"Got textheight from DrawTextW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
}
|
||||
|
||||
|
||||
/* DT_SINGLELINE tests */
|
||||
|
||||
heightcheck = textheight = DrawTextExW(hdc, textW, 0, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextW(hdc, textW, 0, &rect, DT_CALCRECT|DT_SINGLELINE);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
heightcheck = textheight = DrawTextExW(hdc, emptystringW, -1, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
||||
ok( !EMPTY(rect) && MODIFIED(rect),
|
||||
"rectangle should be modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextW(hdc, emptystringW, -1, &rect, DT_CALCRECT|DT_SINGLELINE);
|
||||
ok( !EMPTY(rect) && MODIFIED(rect),
|
||||
"rectangle should be modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
if (conform_xp) {
|
||||
/* Crashes on NT4 */
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
heightcheck = textheight = DrawTextExW(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextW(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
ok(textheight==0,"Got textheight from DrawTextW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
}
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
heightcheck = textheight = DrawTextExW(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
|
||||
SetRect( &rect, 10,10, 100, 100);
|
||||
textheight = DrawTextW(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE);
|
||||
ok( !EMPTY(rect) && !MODIFIED(rect),
|
||||
"rectangle should NOT be empty and NOT modified got %d,%d-%d,%d\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
|
||||
/* further tests with NULL and empty strings */
|
||||
heightcheck = textheight = DrawTextW(hdc, textW, 0, &rect, 0);
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
|
||||
textheight = DrawTextExW(hdc, textW, 0, &rect, 0, NULL );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
heightcheck = textheight = DrawTextW(hdc, emptystringW, 0, &rect, 0);
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
|
||||
textheight = DrawTextExW(hdc, emptystringW, 0, &rect, 0, NULL );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
heightcheck = textheight = DrawTextW(hdc, NULL, 0, &rect, 0);
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextW\n");
|
||||
textheight = DrawTextExW(hdc, NULL, 0, &rect, 0, NULL );
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
heightcheck = textheight = DrawTextW(hdc, emptystringW, -1, &rect, 0);
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
|
||||
textheight = DrawTextExW(hdc, emptystringW, -1, &rect, 0, NULL );
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
if (conform_xp) {
|
||||
/* Crashes on NT4 */
|
||||
heightcheck = textheight = DrawTextW(hdc, NULL, -1, &rect, 0);
|
||||
ok(textheight==0,"Got textheight from DrawTextW\n");
|
||||
textheight = DrawTextExW(hdc, NULL, -1, &rect, 0, NULL );
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
heightcheck = textheight = DrawTextW(hdc, NULL, 10, &rect, 0);
|
||||
ok(textheight==0,"Got textheight from DrawTextW\n");
|
||||
textheight = DrawTextExW(hdc, NULL, 10, &rect, 0, NULL );
|
||||
ok(textheight==0,"Got textheight from DrawTextW\n");
|
||||
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
||||
}
|
||||
|
||||
dtp.cbSize = -1; /* Invalid */
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExW(hdc, textW, 0, &rect, 0, &dtp);
|
||||
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExW(hdc, emptystringW, 0, &rect, 0, &dtp);
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExW(hdc, NULL, 0, &rect, 0, &dtp);
|
||||
if (conform_xp)
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExW(hdc, emptystringW, -1, &rect, 0, &dtp);
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
if (conform_xp) {
|
||||
/* Crashes on NT4 */
|
||||
dtp.uiLengthDrawn = 1337;
|
||||
textheight = DrawTextExW(hdc, NULL, -1, &rect, 0, &dtp);
|
||||
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
||||
ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
|
||||
}
|
||||
}
|
||||
|
||||
/* More test cases from bug 12226 */
|
||||
SetRect(&rect, 0, 0, 0, 0);
|
||||
textheight = DrawTextA(hdc, emptystring, -1, &rect, DT_CALCRECT | DT_LEFT | DT_SINGLELINE);
|
||||
todo_wine ok(textheight, "DrawTextA error %u\n", GetLastError());
|
||||
ok(textheight, "DrawTextA error %u\n", GetLastError());
|
||||
ok(0 == rect.left, "expected 0, got %d\n", rect.left);
|
||||
ok(0 == rect.right, "expected 0, got %d\n", rect.right);
|
||||
ok(0 == rect.top, "expected 0, got %d\n", rect.top);
|
||||
todo_wine ok(rect.bottom, "rect.bottom should not be 0\n");
|
||||
ok(rect.bottom, "rect.bottom should not be 0\n");
|
||||
|
||||
SetRect(&rect, 0, 0, 0, 0);
|
||||
textheight = DrawTextW(hdc, emptystringW, -1, &rect, DT_CALCRECT | DT_LEFT | DT_SINGLELINE);
|
||||
|
@ -171,11 +539,11 @@ static void test_DrawTextCalcRect(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
todo_wine ok(textheight, "DrawTextW error %u\n", GetLastError());
|
||||
ok(textheight, "DrawTextW error %u\n", GetLastError());
|
||||
ok(0 == rect.left, "expected 0, got %d\n", rect.left);
|
||||
ok(0 == rect.right, "expected 0, got %d\n", rect.right);
|
||||
ok(0 == rect.top, "expected 0, got %d\n", rect.top);
|
||||
todo_wine ok(rect.bottom, "rect.bottom should not be 0\n");
|
||||
ok(rect.bottom, "rect.bottom should not be 0\n");
|
||||
}
|
||||
|
||||
SelectObject(hdc, hOldFont);
|
||||
|
|
|
@ -862,20 +862,8 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
|
|||
if (dtp) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n",
|
||||
dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
|
||||
|
||||
if (!str || count == 0) return 0;
|
||||
if (count == -1)
|
||||
{
|
||||
count = strlenW(str);
|
||||
if (count == 0)
|
||||
{
|
||||
if( flags & DT_CALCRECT)
|
||||
{
|
||||
rect->right = rect->left;
|
||||
rect->bottom = rect->top;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (!str) return 0;
|
||||
|
||||
strPtr = str;
|
||||
|
||||
if (flags & DT_SINGLELINE)
|
||||
|
@ -887,6 +875,29 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
|
|||
else
|
||||
lh = tm.tmHeight;
|
||||
|
||||
if (str[0] && count == 0)
|
||||
return lh;
|
||||
|
||||
if (dtp && dtp->cbSize != sizeof(DRAWTEXTPARAMS))
|
||||
return 0;
|
||||
|
||||
if (count == -1)
|
||||
{
|
||||
count = strlenW(str);
|
||||
if (count == 0)
|
||||
{
|
||||
if( flags & DT_CALCRECT)
|
||||
{
|
||||
rect->right = rect->left;
|
||||
if( flags & DT_SINGLELINE)
|
||||
rect->bottom = rect->top + lh;
|
||||
else
|
||||
rect->bottom = rect->top;
|
||||
}
|
||||
return lh;
|
||||
}
|
||||
}
|
||||
|
||||
if (dtp)
|
||||
{
|
||||
lmargin = dtp->iLeftMargin * tm.tmAveCharWidth;
|
||||
|
@ -1031,14 +1042,30 @@ INT WINAPI DrawTextExA( HDC hdc, LPSTR str, INT count,
|
|||
UINT cp;
|
||||
|
||||
if (!count) return 0;
|
||||
if (!str && count > 0) return 0;
|
||||
if( !str || ((count == -1) && !(count = strlen(str))))
|
||||
{
|
||||
int lh;
|
||||
TEXTMETRICA tm;
|
||||
|
||||
if (dtp && dtp->cbSize != sizeof(DRAWTEXTPARAMS))
|
||||
return 0;
|
||||
|
||||
GetTextMetricsA(hdc, &tm);
|
||||
if (flags & DT_EXTERNALLEADING)
|
||||
lh = tm.tmHeight + tm.tmExternalLeading;
|
||||
else
|
||||
lh = tm.tmHeight;
|
||||
|
||||
if( flags & DT_CALCRECT)
|
||||
{
|
||||
rect->right = rect->left;
|
||||
rect->bottom = rect->top;
|
||||
if( flags & DT_SINGLELINE)
|
||||
rect->bottom = rect->top + lh;
|
||||
else
|
||||
rect->bottom = rect->top;
|
||||
}
|
||||
return 0;
|
||||
return lh;
|
||||
}
|
||||
cp = GdiGetCodePage( hdc );
|
||||
wcount = MultiByteToWideChar( cp, 0, str, count, NULL, 0 );
|
||||
|
|
Loading…
Reference in New Issue