2004-07-21 00:09:14 +02:00
|
|
|
/*
|
|
|
|
* DrawText tests
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Zach Gorman
|
2016-07-08 05:11:42 +02:00
|
|
|
* Copyright 2007,2016 Dmitry Timoshkov
|
2004-07-21 00:09:14 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-07-21 00:09:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
2009-05-24 19:47:24 +02:00
|
|
|
#define MODIFIED(rect) (rect.left == 10 && rect.right != 100 && rect.top == 10 && rect.bottom != 100)
|
2008-10-13 17:51:52 +02:00
|
|
|
#define EMPTY(rect) (rect.left == rect.right && rect.bottom == rect.top)
|
2004-07-21 00:09:14 +02:00
|
|
|
|
|
|
|
static void test_DrawTextCalcRect(void)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hFont, hOldFont;
|
|
|
|
LOGFONTA lf;
|
2006-08-07 21:52:33 +02:00
|
|
|
static CHAR text[] = "Example text for testing DrawText in "
|
2004-07-21 00:09:14 +02:00
|
|
|
"MM_HIENGLISH mode";
|
2006-08-07 21:52:33 +02:00
|
|
|
static WCHAR textW[] = {'W','i','d','e',' ','c','h','a','r',' ',
|
2006-01-27 15:47:15 +01:00
|
|
|
's','t','r','i','n','g','\0'};
|
2006-08-07 21:52:33 +02:00
|
|
|
static CHAR emptystring[] = "";
|
|
|
|
static WCHAR emptystringW[] = { 0 };
|
2014-03-11 18:41:43 +01:00
|
|
|
static CHAR wordbreak_text[] = "line1 line2";
|
|
|
|
static WCHAR wordbreak_textW[] = {'l','i','n','e','1',' ','l','i','n','e','2',0};
|
2016-03-02 05:22:10 +01:00
|
|
|
static char tabstring[] = "one\ttwo";
|
2008-10-13 17:51:52 +02:00
|
|
|
INT textlen, textheight, heightcheck;
|
2016-03-02 05:22:10 +01:00
|
|
|
RECT rect = { 0, 0, 100, 0 }, rect2;
|
2004-12-27 18:26:37 +01:00
|
|
|
BOOL ret;
|
2008-10-13 17:51:52 +02:00
|
|
|
DRAWTEXTPARAMS dtp;
|
|
|
|
BOOL conform_xp = TRUE;
|
2004-07-21 00:09:14 +02:00
|
|
|
|
|
|
|
/* Initialization */
|
|
|
|
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
|
|
|
|
0, 0, 200, 200, 0, 0, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError());
|
2004-07-21 00:09:14 +02:00
|
|
|
hdc = GetDC(hwnd);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hdc != 0, "GetDC error %u\n", GetLastError());
|
2004-07-21 00:09:14 +02:00
|
|
|
trace("hdc %p\n", hdc);
|
2005-03-31 12:07:26 +02:00
|
|
|
textlen = lstrlenA(text);
|
2004-07-21 00:09:14 +02:00
|
|
|
|
|
|
|
/* LOGFONT initialization */
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
lf.lfHeight = 0; /* mapping mode dependent */
|
|
|
|
lf.lfQuality = DEFAULT_QUALITY;
|
|
|
|
lstrcpyA(lf.lfFaceName, "Arial");
|
|
|
|
|
|
|
|
/* DrawText in MM_HIENGLISH with DT_CALCRECT */
|
|
|
|
SetMapMode(hdc, MM_HIENGLISH);
|
|
|
|
lf.lfHeight = 100 * 9 / 72; /* 9 point */
|
|
|
|
hFont = CreateFontIndirectA(&lf);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hFont != 0, "CreateFontIndirectA error %u\n",
|
2004-07-21 00:09:14 +02:00
|
|
|
GetLastError());
|
|
|
|
hOldFont = SelectObject(hdc, hFont);
|
|
|
|
|
2005-03-31 12:07:26 +02:00
|
|
|
textheight = DrawTextA(hdc, text, textlen, &rect, DT_CALCRECT |
|
2004-07-21 00:09:14 +02:00
|
|
|
DT_EXTERNALLEADING | DT_WORDBREAK | DT_NOCLIP | DT_LEFT |
|
2004-12-27 18:26:37 +01:00
|
|
|
DT_NOPREFIX);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( textheight, "DrawTextA error %u\n", GetLastError());
|
2004-07-21 00:09:14 +02:00
|
|
|
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("MM_HIENGLISH rect.bottom %d\n", rect.bottom);
|
2009-09-25 23:55:45 +02:00
|
|
|
ok(rect.bottom < 0, "In MM_HIENGLISH, DrawText with "
|
2004-07-21 00:09:14 +02:00
|
|
|
"DT_CALCRECT should return a negative rectangle bottom. "
|
2006-10-07 21:45:11 +02:00
|
|
|
"(bot=%d)\n", rect.bottom);
|
2004-07-21 00:09:14 +02:00
|
|
|
|
|
|
|
SelectObject(hdc, hOldFont);
|
2004-12-27 18:26:37 +01:00
|
|
|
ret = DeleteObject(hFont);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( ret, "DeleteObject error %u\n", GetLastError());
|
2004-07-21 00:09:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* DrawText in MM_TEXT with DT_CALCRECT */
|
|
|
|
SetMapMode(hdc, MM_TEXT);
|
|
|
|
lf.lfHeight = -MulDiv(9, GetDeviceCaps(hdc,
|
|
|
|
LOGPIXELSY), 72); /* 9 point */
|
|
|
|
hFont = CreateFontIndirectA(&lf);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hFont != 0, "CreateFontIndirectA error %u\n",
|
2004-07-21 00:09:14 +02:00
|
|
|
GetLastError());
|
|
|
|
hOldFont = SelectObject(hdc, hFont);
|
|
|
|
|
2005-03-31 12:07:26 +02:00
|
|
|
textheight = DrawTextA(hdc, text, textlen, &rect, DT_CALCRECT |
|
2004-07-21 00:09:14 +02:00
|
|
|
DT_EXTERNALLEADING | DT_WORDBREAK | DT_NOCLIP | DT_LEFT |
|
2004-12-27 18:26:37 +01:00
|
|
|
DT_NOPREFIX);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( textheight, "DrawTextA error %u\n", GetLastError());
|
2004-07-21 00:09:14 +02:00
|
|
|
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("MM_TEXT rect.bottom %d\n", rect.bottom);
|
2004-07-21 00:09:14 +02:00
|
|
|
ok(rect.bottom > 0, "In MM_TEXT, DrawText with DT_CALCRECT "
|
2006-10-07 21:45:11 +02:00
|
|
|
"should return a positive rectangle bottom. (bot=%d)\n",
|
2004-07-21 00:09:14 +02:00
|
|
|
rect.bottom);
|
|
|
|
|
2006-01-27 15:47:15 +01:00
|
|
|
/* empty or null text should in some cases calc an empty rectangle */
|
2008-10-13 17:51:52 +02:00
|
|
|
|
2006-01-27 15:47:15 +01:00
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
2008-10-13 17:51:52 +02:00
|
|
|
heightcheck = textheight = DrawTextExA(hdc, text, 0, &rect, DT_CALCRECT, NULL );
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2011-07-27 04:11:34 +02:00
|
|
|
ok(textheight==0,"Got textheight from DrawTextExA\n");
|
2008-10-13 17:51:52 +02:00
|
|
|
|
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
textheight = DrawTextA(hdc, text, 0, &rect, DT_CALCRECT);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
if (conform_xp)
|
|
|
|
ok(textheight==0,"Got textheight from DrawTextA\n");
|
|
|
|
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
|
|
|
|
2006-01-27 15:47:15 +01:00
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
SetLastError( 0);
|
2008-10-13 17:51:52 +02:00
|
|
|
heightcheck = textheight = DrawTextExA(hdc, emptystring, -1, &rect, DT_CALCRECT, NULL );
|
2016-06-20 12:08:13 +02:00
|
|
|
ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
|
|
|
|
|
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
textheight = DrawTextA(hdc, emptystring, -1, &rect, DT_CALCRECT);
|
2016-06-20 12:08:13 +02:00
|
|
|
ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
|
|
|
|
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
|
|
|
|
2006-01-27 15:47:15 +01:00
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
SetLastError( 0);
|
2008-10-13 17:51:52 +02:00
|
|
|
heightcheck = textheight = DrawTextExA(hdc, NULL, -1, &rect, DT_CALCRECT, NULL );
|
2016-06-20 12:06:45 +02:00
|
|
|
ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
if (!textheight) /* Windows NT 4 */
|
|
|
|
{
|
|
|
|
if (conform_xp)
|
2008-10-19 18:55:26 +02:00
|
|
|
win_skip("XP conformity failed, skipping XP tests. Probably winNT\n");
|
2008-10-13 17:51:52 +02:00
|
|
|
conform_xp = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
|
|
|
|
|
2006-01-27 15:47:15 +01:00
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
2008-10-13 17:51:52 +02:00
|
|
|
textheight = DrawTextA(hdc, NULL, -1, &rect, DT_CALCRECT);
|
2016-06-20 12:06:45 +02:00
|
|
|
ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 );
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 );
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 );
|
2016-06-20 12:08:13 +02:00
|
|
|
ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
|
|
|
|
wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
2016-06-20 12:08:13 +02:00
|
|
|
ok(!EMPTY(rect) && MODIFIED (rect), "rectangle should be modified got %s\n",
|
|
|
|
wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 );
|
2016-06-20 12:06:45 +02:00
|
|
|
ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
|
|
|
|
wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
2016-06-20 12:06:45 +02:00
|
|
|
ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
|
|
|
|
wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 );
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
2006-01-27 15:47:15 +01:00
|
|
|
|
2009-02-02 19:47:00 +01:00
|
|
|
/* Margin calculations */
|
|
|
|
dtp.cbSize = sizeof(dtp);
|
|
|
|
dtp.iLeftMargin = 0;
|
|
|
|
dtp.iRightMargin = 0;
|
2016-03-03 09:59:46 +01:00
|
|
|
SetRectEmpty(&rect);
|
2009-02-02 19:47:00 +01:00
|
|
|
DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
|
|
|
|
textlen = rect.right; /* Width without margin */
|
|
|
|
dtp.iLeftMargin = 8;
|
2016-03-03 09:59:46 +01:00
|
|
|
SetRectEmpty(&rect);
|
2009-02-02 19:47:00 +01:00
|
|
|
DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
|
|
|
|
ok(rect.right==dtp.iLeftMargin+textlen ,"Incorrect left margin calculated rc(%d,%d)\n", rect.left, rect.right);
|
|
|
|
dtp.iLeftMargin = 0;
|
|
|
|
dtp.iRightMargin = 8;
|
2016-03-03 09:59:46 +01:00
|
|
|
SetRectEmpty(&rect);
|
2009-02-02 19:47:00 +01:00
|
|
|
DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
|
|
|
|
ok(rect.right==dtp.iRightMargin+textlen ,"Incorrect right margin calculated rc(%d,%d)\n", rect.left, rect.right);
|
|
|
|
|
2006-01-27 15:47:15 +01:00
|
|
|
/* Wide char versions */
|
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
SetLastError( 0);
|
2008-10-13 17:51:52 +02:00
|
|
|
heightcheck = textheight = DrawTextExW(hdc, textW, 0, &rect, DT_CALCRECT, NULL );
|
2006-01-27 15:47:15 +01:00
|
|
|
if( GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) {
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
|
|
|
|
2006-01-27 15:47:15 +01:00
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
2008-10-13 17:51:52 +02:00
|
|
|
textheight = DrawTextW(hdc, textW, 0, &rect, DT_CALCRECT);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 );
|
2016-06-20 12:08:13 +02:00
|
|
|
ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
|
|
|
|
|
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
textheight = DrawTextW(hdc, emptystringW, -1, &rect, DT_CALCRECT);
|
2016-06-20 12:08:13 +02:00
|
|
|
ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 );
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
if (textheight) /* windows 2000 */
|
|
|
|
{
|
|
|
|
if (conform_xp)
|
2008-10-19 18:55:26 +02:00
|
|
|
win_skip("XP conformity failed, skipping XP tests. Probably win 2000\n");
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 */
|
2008-10-09 11:59:42 +02:00
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
2008-10-13 17:51:52 +02:00
|
|
|
heightcheck = textheight = DrawTextExW(hdc, NULL, -1, &rect, DT_CALCRECT, NULL );
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
|
|
|
|
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
textheight = DrawTextW(hdc, NULL, -1, &rect, DT_CALCRECT);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 );
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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 );
|
2016-06-20 12:08:13 +02:00
|
|
|
ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
|
|
|
|
wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
2016-06-20 12:08:13 +02:00
|
|
|
ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
|
|
|
|
wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
|
|
|
|
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
|
|
|
|
|
|
|
if (conform_xp) {
|
2008-10-09 11:59:42 +02:00
|
|
|
/* Crashes on NT4 */
|
2008-10-13 17:51:52 +02:00
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
heightcheck = textheight = DrawTextExW(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
|
|
|
|
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
textheight = DrawTextW(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight==0,"Got textheight from DrawTextW\n");
|
|
|
|
ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
|
2008-10-09 11:59:42 +02:00
|
|
|
}
|
2008-10-13 17:51:52 +02:00
|
|
|
|
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
|
|
|
heightcheck = textheight = DrawTextExW(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
if (conform_xp)
|
|
|
|
ok(textheight==0,"Got textheight from DrawTextExW\n");
|
|
|
|
|
2006-01-27 15:47:15 +01:00
|
|
|
SetRect( &rect, 10,10, 100, 100);
|
2008-10-13 17:51:52 +02:00
|
|
|
textheight = DrawTextW(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE);
|
2016-06-20 12:07:20 +02:00
|
|
|
ok(!IsRectEmpty(&rect) && !MODIFIED(rect),
|
|
|
|
"rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
|
2008-10-13 17:51:52 +02:00
|
|
|
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);
|
|
|
|
}
|
2006-01-27 15:47:15 +01:00
|
|
|
}
|
2006-08-07 21:52:33 +02:00
|
|
|
|
2008-03-27 18:58:08 +01:00
|
|
|
/* More test cases from bug 12226 */
|
2016-03-03 09:59:46 +01:00
|
|
|
SetRectEmpty(&rect);
|
2008-03-27 18:58:08 +01:00
|
|
|
textheight = DrawTextA(hdc, emptystring, -1, &rect, DT_CALCRECT | DT_LEFT | DT_SINGLELINE);
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight, "DrawTextA error %u\n", GetLastError());
|
2008-03-27 18:58:08 +01:00
|
|
|
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);
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(rect.bottom, "rect.bottom should not be 0\n");
|
2008-03-27 18:58:08 +01:00
|
|
|
|
2016-03-03 09:59:46 +01:00
|
|
|
SetRectEmpty(&rect);
|
2008-03-27 18:58:08 +01:00
|
|
|
textheight = DrawTextW(hdc, emptystringW, -1, &rect, DT_CALCRECT | DT_LEFT | DT_SINGLELINE);
|
2008-08-04 23:06:54 +02:00
|
|
|
if (!textheight && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip( "DrawTextW not implemented\n" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(textheight, "DrawTextW error %u\n", GetLastError());
|
2008-08-04 23:06:54 +02:00
|
|
|
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);
|
2008-10-13 17:51:52 +02:00
|
|
|
ok(rect.bottom, "rect.bottom should not be 0\n");
|
2008-08-04 23:06:54 +02:00
|
|
|
}
|
2008-03-27 18:58:08 +01:00
|
|
|
|
2014-03-11 18:41:43 +01:00
|
|
|
SetRect(&rect, 0, 0, 1, 1);
|
|
|
|
heightcheck = DrawTextA(hdc, wordbreak_text, -1, &rect, DT_CALCRECT);
|
|
|
|
SetRect(&rect, 0, 0, 1, 1);
|
|
|
|
textheight = DrawTextA(hdc, wordbreak_text, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
|
|
|
|
ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n",
|
|
|
|
textheight, heightcheck * 2);
|
2014-06-13 10:01:22 +02:00
|
|
|
SetRect(&rect, 0, 0, 1, 1);
|
|
|
|
textheight = DrawTextA(hdc, wordbreak_text, -1, &rect, DT_CALCRECT | DT_WORDBREAK | DT_EDITCONTROL);
|
|
|
|
ok(textheight >= heightcheck * 6, "Got unexpected textheight %d, expected at least %d.\n",
|
|
|
|
textheight, heightcheck * 6);
|
2014-03-11 18:41:43 +01:00
|
|
|
|
|
|
|
SetRect(&rect, 0, 0, 1, 1);
|
|
|
|
heightcheck = DrawTextW(hdc, wordbreak_textW, -1, &rect, DT_CALCRECT);
|
|
|
|
SetRect(&rect, 0, 0, 1, 1);
|
|
|
|
textheight = DrawTextW(hdc, wordbreak_textW, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
|
|
|
|
ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n",
|
|
|
|
textheight, heightcheck * 2);
|
2014-06-13 10:01:22 +02:00
|
|
|
SetRect(&rect, 0, 0, 1, 1);
|
|
|
|
textheight = DrawTextW(hdc, wordbreak_textW, -1, &rect, DT_CALCRECT | DT_WORDBREAK | DT_EDITCONTROL);
|
|
|
|
ok(textheight >= heightcheck * 6, "Got unexpected textheight %d, expected at least %d.\n",
|
|
|
|
textheight, heightcheck * 6);
|
2014-03-11 18:41:43 +01:00
|
|
|
|
2016-03-02 05:22:10 +01:00
|
|
|
/* DT_TABSTOP | DT_EXPANDTABS tests */
|
|
|
|
SetRect( &rect, 0,0, 10, 10);
|
|
|
|
textheight = DrawTextA(hdc, tabstring, -1, &rect, DT_TABSTOP | DT_EXPANDTABS );
|
|
|
|
ok(textheight >= heightcheck, "Got unexpected textheight %d\n", textheight);
|
|
|
|
|
|
|
|
SetRect( &rect, 0,0, 10, 10);
|
|
|
|
memset(&dtp, 0, sizeof(dtp));
|
|
|
|
dtp.cbSize = sizeof(dtp);
|
|
|
|
textheight = DrawTextExA(hdc, tabstring, -1, &rect, DT_CALCRECT, &dtp);
|
|
|
|
ok(textheight >= heightcheck, "Got unexpected textheight %d\n", textheight);
|
|
|
|
ok(dtp.iTabLength == 0, "invalid dtp.iTabLength = %i\n",dtp.iTabLength);
|
|
|
|
|
|
|
|
SetRect( &rect2, 0,0, 10, 10);
|
|
|
|
memset(&dtp, 0, sizeof(dtp));
|
|
|
|
dtp.cbSize = sizeof(dtp);
|
|
|
|
textheight = DrawTextExA(hdc, tabstring, -1, &rect2, DT_CALCRECT | DT_TABSTOP | DT_EXPANDTABS, &dtp);
|
|
|
|
ok(textheight >= heightcheck, "Got unexpected textheight %d\n", textheight);
|
|
|
|
ok(dtp.iTabLength == 0, "invalid dtp.iTabLength = %i\n",dtp.iTabLength);
|
|
|
|
ok(rect.left == rect2.left && rect.right != rect2.right && rect.top == rect2.top && rect.bottom == rect2.bottom,
|
2016-06-16 10:32:02 +02:00
|
|
|
"incorrect rect %s rect2 %s\n", wine_dbgstr_rect(&rect), wine_dbgstr_rect(&rect2));
|
2016-03-02 05:22:10 +01:00
|
|
|
|
|
|
|
SetRect( &rect, 0,0, 10, 10);
|
|
|
|
memset(&dtp, 0, sizeof(dtp));
|
|
|
|
dtp.cbSize = sizeof(dtp);
|
|
|
|
dtp.iTabLength = 8;
|
|
|
|
textheight = DrawTextExA(hdc, tabstring, -1, &rect, DT_CALCRECT | DT_TABSTOP | DT_EXPANDTABS, &dtp);
|
|
|
|
ok(textheight >= heightcheck, "Got unexpected textheight %d\n", textheight);
|
|
|
|
ok(dtp.iTabLength == 8, "invalid dtp.iTabLength = %i\n",dtp.iTabLength);
|
|
|
|
ok(rect.left == rect2.left, "unexpected value %d, got %d\n", rect.left, rect2.left);
|
|
|
|
/* XP, 2003 appear to not give the same values. */
|
|
|
|
ok(rect.right == rect2.right || broken(rect.right > rect2.right), "unexpected value %d, got %d\n",rect.right, rect2.right);
|
|
|
|
ok(rect.top == rect2.top, "unexpected value %d, got %d\n", rect.top, rect2.top);
|
|
|
|
ok(rect.bottom == rect2.bottom , "unexpected value %d, got %d\n", rect.bottom, rect2.bottom);
|
|
|
|
|
|
|
|
|
2004-07-21 00:09:14 +02:00
|
|
|
SelectObject(hdc, hOldFont);
|
2004-12-27 18:26:37 +01:00
|
|
|
ret = DeleteObject(hFont);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( ret, "DeleteObject error %u\n", GetLastError());
|
2004-07-21 00:09:14 +02:00
|
|
|
|
|
|
|
/* Clean up */
|
2004-12-27 18:26:37 +01:00
|
|
|
ret = ReleaseDC(hwnd, hdc);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( ret, "ReleaseDC error %u\n", GetLastError());
|
2004-12-27 18:26:37 +01:00
|
|
|
ret = DestroyWindow(hwnd);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( ret, "DestroyWindow error %u\n", GetLastError());
|
2004-07-21 00:09:14 +02:00
|
|
|
}
|
|
|
|
|
2005-10-26 12:04:21 +02:00
|
|
|
/* replace tabs by \t */
|
2006-08-07 21:52:33 +02:00
|
|
|
static void strfmt( const char *str, char *strout)
|
2005-10-26 12:04:21 +02:00
|
|
|
{
|
|
|
|
unsigned int i,j ;
|
|
|
|
for(i=0,j=0;i<=strlen(str);i++,j++)
|
|
|
|
if((strout[j]=str[i])=='\t') {
|
|
|
|
strout[j++]='\\';
|
|
|
|
strout[j]='t';
|
|
|
|
}
|
|
|
|
}
|
2006-08-07 21:52:33 +02:00
|
|
|
|
2005-10-26 12:04:21 +02:00
|
|
|
|
|
|
|
#define TABTEST( tabval, tabcount, string, _exp) \
|
2015-11-13 21:52:10 +01:00
|
|
|
{ int i; char strdisp[64];\
|
2005-10-26 12:04:21 +02:00
|
|
|
for(i=0;i<8;i++) tabs[i]=(i+1)*(tabval); \
|
|
|
|
extent = GetTabbedTextExtentA( hdc, string, strlen( string), (tabcount), tabs); \
|
|
|
|
strfmt( string, strdisp); \
|
|
|
|
/* trace( "Extent is %08lx\n", extent); */\
|
2015-11-13 21:52:10 +01:00
|
|
|
ok( extent == _exp, "Test case \"%s\". Text extent is 0x%x, expected 0x%x tab %d tabcount %d\n", \
|
|
|
|
strdisp, extent, _exp, tabval, tabcount); \
|
2005-10-26 12:04:21 +02:00
|
|
|
} \
|
|
|
|
|
|
|
|
|
2006-02-06 13:13:28 +01:00
|
|
|
static void test_TabbedText(void)
|
2005-10-26 12:04:21 +02:00
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
HDC hdc;
|
|
|
|
BOOL ret;
|
|
|
|
TEXTMETRICA tm;
|
|
|
|
DWORD extent;
|
|
|
|
INT tabs[8], cx, cy, tab, tabcount,t,align;
|
|
|
|
|
|
|
|
/* Initialization */
|
|
|
|
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
|
|
|
|
0, 0, 200, 200, 0, 0, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError());
|
2005-10-26 12:04:21 +02:00
|
|
|
hdc = GetDC(hwnd);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hdc != 0, "GetDC error %u\n", GetLastError());
|
2005-10-26 12:04:21 +02:00
|
|
|
|
|
|
|
ret = GetTextMetricsA( hdc, &tm);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( ret, "GetTextMetrics error %u\n", GetLastError());
|
2005-10-26 12:04:21 +02:00
|
|
|
|
2011-04-23 13:36:12 +02:00
|
|
|
extent = GetTabbedTextExtentA( hdc, "x", 0, 1, tabs);
|
|
|
|
ok( extent == 0, "GetTabbedTextExtentA returned non-zero on nCount == 0\n");
|
|
|
|
|
2005-10-26 12:04:21 +02:00
|
|
|
extent = GetTabbedTextExtentA( hdc, "x", 1, 1, tabs);
|
|
|
|
cx = LOWORD( extent);
|
|
|
|
cy = HIWORD( extent);
|
|
|
|
trace( "cx is %d cy is %d\n", cx, cy);
|
|
|
|
|
|
|
|
align=1;
|
|
|
|
for( t=-1; t<=1; t++) { /* slightly adjust the 4 char tabstop, to
|
|
|
|
catch the one off errors */
|
|
|
|
tab = (cx *4 + t);
|
|
|
|
/* test the special case tabcount =1 and the general array (80 of tabs */
|
|
|
|
for( tabcount = 1; tabcount <= 8; tabcount +=7) {
|
2015-11-13 21:52:10 +01:00
|
|
|
TABTEST( align * tab, tabcount, "\t", MAKELONG(tab, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xxx\t", MAKELONG(tab, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "\tx", MAKELONG(tab+cx, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "\t\t", MAKELONG(tab*2, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "\tx\t", MAKELONG(tab*2, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "x\tx", MAKELONG(tab+cx, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xx\tx", MAKELONG(tab+cx, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xxx\tx", MAKELONG(tab+cx, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xxxx\tx", MAKELONG(t>0 ? tab + cx : 2*tab+cx, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xxxxx\tx", MAKELONG(2*tab+cx, cy))
|
2005-10-26 12:04:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
align=-1;
|
|
|
|
for( t=-1; t<=1; t++) { /* slightly adjust the 4 char tabstop, to
|
|
|
|
catch the one off errors */
|
|
|
|
tab = (cx *4 + t);
|
|
|
|
/* test the special case tabcount =1 and the general array (8) of tabs */
|
|
|
|
for( tabcount = 1; tabcount <= 8; tabcount +=7) {
|
2015-11-13 21:52:10 +01:00
|
|
|
TABTEST( align * tab, tabcount, "\t", MAKELONG(tab, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xxx\t", MAKELONG(tab, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "\tx", MAKELONG(tab, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "\t\t", MAKELONG(tab*2, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "\tx\t", MAKELONG(tab*2, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "x\tx", MAKELONG(tab, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xx\tx", MAKELONG(tab, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xxx\tx", MAKELONG(4 * cx >= tab ? 2*tab :tab, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xxxx\tx", MAKELONG(2*tab, cy))
|
|
|
|
TABTEST( align * tab, tabcount, "xxxxx\tx", MAKELONG(2*tab, cy))
|
2005-10-26 12:04:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-11 11:06:19 +01:00
|
|
|
ReleaseDC( hwnd, hdc );
|
|
|
|
DestroyWindow( hwnd );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_DrawState(void)
|
|
|
|
{
|
|
|
|
static const char text[] = "Sample text string";
|
|
|
|
HWND hwnd;
|
|
|
|
HDC hdc;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
|
|
|
|
0, 0, 200, 200, 0, 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
assert(hdc);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-23 07:54:20 +02:00
|
|
|
ret = DrawStateA(hdc, GetStockObject(DKGRAY_BRUSH), NULL, (LPARAM)text, strlen(text),
|
2007-01-11 11:06:19 +01:00
|
|
|
0, 0, 10, 10, DST_TEXT);
|
|
|
|
ok(ret, "DrawState error %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-23 07:54:20 +02:00
|
|
|
ret = DrawStateA(hdc, GetStockObject(DKGRAY_BRUSH), NULL, (LPARAM)text, 0,
|
2007-01-11 11:06:19 +01:00
|
|
|
0, 0, 10, 10, DST_TEXT);
|
|
|
|
ok(ret, "DrawState error %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-23 07:54:20 +02:00
|
|
|
ret = DrawStateA(hdc, GetStockObject(DKGRAY_BRUSH), NULL, 0, strlen(text),
|
2007-01-11 11:06:19 +01:00
|
|
|
0, 0, 10, 10, DST_TEXT);
|
2008-10-14 14:29:28 +02:00
|
|
|
ok(!ret || broken(ret) /* win98 */, "DrawState succeeded\n");
|
2007-01-11 11:06:19 +01:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "not expected error %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-23 07:54:20 +02:00
|
|
|
ret = DrawStateA(hdc, GetStockObject(DKGRAY_BRUSH), NULL, 0, 0,
|
2007-01-11 11:06:19 +01:00
|
|
|
0, 0, 10, 10, DST_TEXT);
|
2008-10-14 14:29:28 +02:00
|
|
|
ok(!ret || broken(ret) /* win98 */, "DrawState succeeded\n");
|
2007-01-11 11:06:19 +01:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "not expected error %u\n", GetLastError());
|
2005-10-26 12:04:21 +02:00
|
|
|
|
2007-01-11 11:06:19 +01:00
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
DestroyWindow(hwnd);
|
2005-10-26 12:04:21 +02:00
|
|
|
}
|
|
|
|
|
2016-07-08 05:11:42 +02:00
|
|
|
static void test_CharToOem_OemToChar(void)
|
|
|
|
{
|
2016-07-08 05:12:11 +02:00
|
|
|
static const WCHAR helloWorldW[] = {'H','e','l','l','o',' ','W','o','r','l','d',0};
|
|
|
|
static const WCHAR emptyW[] = {0};
|
2016-07-08 05:11:42 +02:00
|
|
|
static const char helloWorld[] = "Hello World";
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
BOOL src, dst, ret;
|
|
|
|
}
|
|
|
|
tests[] =
|
|
|
|
{
|
|
|
|
{ FALSE, FALSE, FALSE },
|
|
|
|
{ TRUE, FALSE, FALSE },
|
|
|
|
{ FALSE, TRUE, FALSE },
|
|
|
|
{ TRUE, TRUE, TRUE },
|
|
|
|
};
|
|
|
|
BOOL ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
|
|
|
|
{
|
|
|
|
const char *expected = tests[i].ret ? helloWorld : "";
|
|
|
|
const char *src = tests[i].src ? helloWorld : NULL;
|
|
|
|
char buf[64], *dst = tests[i].dst ? buf : NULL;
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
ret = CharToOemA(src, dst);
|
|
|
|
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
|
|
|
|
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
ret = CharToOemBuffA(src, dst, sizeof(helloWorld));
|
|
|
|
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
|
|
|
|
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
ret = OemToCharA(src, dst);
|
|
|
|
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
|
|
|
|
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
ret = OemToCharBuffA(src, dst, sizeof(helloWorld));
|
|
|
|
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
|
|
|
|
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
|
|
|
|
}
|
2016-07-08 05:12:11 +02:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
|
|
|
|
{
|
|
|
|
const char *expected = tests[i].ret ? helloWorld : "";
|
|
|
|
const WCHAR *src = tests[i].src ? helloWorldW : NULL;
|
|
|
|
char buf[64], *dst = tests[i].dst ? buf : NULL;
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
ret = CharToOemW(src, dst);
|
|
|
|
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
|
|
|
|
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
ret = CharToOemBuffW(src, dst, sizeof(helloWorldW)/sizeof(WCHAR));
|
|
|
|
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
|
|
|
|
ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
|
|
|
|
{
|
|
|
|
const WCHAR *expected = tests[i].ret ? helloWorldW : emptyW;
|
|
|
|
const char *src = tests[i].src ? helloWorld : NULL;
|
|
|
|
WCHAR buf[64], *dst = tests[i].dst ? buf : NULL;
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
ret = OemToCharW(src, dst);
|
|
|
|
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
|
|
|
|
ok(!lstrcmpW(buf, expected), "test %d: got '%s'\n", i, wine_dbgstr_w(buf));
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
ret = OemToCharBuffW(src, dst, sizeof(helloWorld));
|
|
|
|
ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
|
|
|
|
ok(!lstrcmpW(buf, expected), "test %d: got '%s'\n", i, wine_dbgstr_w(buf));
|
|
|
|
}
|
2016-07-08 05:11:42 +02:00
|
|
|
}
|
|
|
|
|
2004-07-21 00:09:14 +02:00
|
|
|
START_TEST(text)
|
|
|
|
{
|
2005-10-26 12:04:21 +02:00
|
|
|
test_TabbedText();
|
2004-07-21 00:09:14 +02:00
|
|
|
test_DrawTextCalcRect();
|
2007-01-11 11:06:19 +01:00
|
|
|
test_DrawState();
|
2016-07-08 05:11:42 +02:00
|
|
|
test_CharToOem_OemToChar();
|
2004-07-21 00:09:14 +02:00
|
|
|
}
|