2010-08-24 13:54:10 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for GetTextFace
|
|
|
|
* PROGRAMMERS: Timo Kreuzer
|
|
|
|
*/
|
2008-10-16 20:16:38 +00:00
|
|
|
|
2013-09-22 17:52:42 +00:00
|
|
|
#include <apitest.h>
|
|
|
|
|
2013-02-05 17:54:22 +00:00
|
|
|
#include <wingdi.h>
|
2010-08-24 13:54:10 +00:00
|
|
|
|
2010-10-17 14:50:02 +00:00
|
|
|
#define TEST(x) ok(x, #x"\n")
|
|
|
|
#define RTEST(x) ok(x, #x"\n")
|
2010-08-24 13:54:10 +00:00
|
|
|
|
|
|
|
void Test_GetTextFace()
|
2008-10-16 20:16:38 +00:00
|
|
|
{
|
|
|
|
HDC hDC;
|
|
|
|
INT ret;
|
2008-10-17 00:28:47 +00:00
|
|
|
INT ret2;
|
|
|
|
WCHAR Buffer[20];
|
2008-10-16 20:16:38 +00:00
|
|
|
|
2008-10-17 00:28:47 +00:00
|
|
|
hDC = CreateCompatibleDC(NULL);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(hDC != 0, "CreateCompatibleDC failed, skipping tests.\n");
|
|
|
|
if (!hDC) return;
|
2008-10-16 20:16:38 +00:00
|
|
|
|
2008-10-17 00:28:47 +00:00
|
|
|
/* Whether asking for the string size (NULL buffer) ignores the size argument */
|
|
|
|
SetLastError(0xE000BEEF);
|
|
|
|
ret = GetTextFaceW(hDC, 0, NULL);
|
2008-10-16 20:16:38 +00:00
|
|
|
TEST(ret != 0);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
|
2008-10-17 00:28:47 +00:00
|
|
|
ret2 = ret;
|
2008-10-16 20:16:38 +00:00
|
|
|
|
2008-10-17 00:28:47 +00:00
|
|
|
SetLastError(0xE000BEEF);
|
|
|
|
ret = GetTextFaceW(hDC, -1, NULL);
|
2008-10-16 20:16:38 +00:00
|
|
|
TEST(ret != 0);
|
2008-10-17 00:28:47 +00:00
|
|
|
TEST(ret == ret2);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
|
2008-10-17 00:28:47 +00:00
|
|
|
ret2 = ret;
|
2008-10-16 20:16:38 +00:00
|
|
|
|
2008-10-17 00:28:47 +00:00
|
|
|
SetLastError(0xE000BEEF);
|
|
|
|
ret = GetTextFaceW(hDC, 10000, NULL);
|
|
|
|
TEST(ret != 0);
|
|
|
|
TEST(ret == ret2);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
|
2008-10-17 00:28:47 +00:00
|
|
|
ret2 = ret;
|
2008-10-16 20:16:38 +00:00
|
|
|
|
2008-10-17 00:28:47 +00:00
|
|
|
/* Whether the buffer is correctly filled */
|
|
|
|
SetLastError(0xE000BEEF);
|
|
|
|
ret = GetTextFaceW(hDC, 20, Buffer);
|
2008-10-16 20:16:38 +00:00
|
|
|
TEST(ret != 0);
|
2008-10-17 00:28:47 +00:00
|
|
|
TEST(ret <= 20);
|
|
|
|
TEST(Buffer[ret - 1] == 0);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
|
2008-10-17 00:28:47 +00:00
|
|
|
|
|
|
|
SetLastError(0xE000BEEF);
|
|
|
|
ret = GetTextFaceW(hDC, 1, Buffer);
|
|
|
|
TEST(ret == 1);
|
|
|
|
TEST(Buffer[ret - 1] == 0);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
|
2008-10-17 00:28:47 +00:00
|
|
|
|
|
|
|
SetLastError(0xE000BEEF);
|
|
|
|
ret = GetTextFaceW(hDC, 2, Buffer);
|
|
|
|
TEST(ret == 2);
|
|
|
|
TEST(Buffer[ret - 1] == 0);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError());
|
2008-10-17 00:28:47 +00:00
|
|
|
|
|
|
|
/* Whether invalid buffer sizes are correctly ignored */
|
|
|
|
SetLastError(0xE000BEEF);
|
|
|
|
ret = GetTextFaceW(hDC, 0, Buffer);
|
|
|
|
TEST(ret == 0);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() == %ld\n", GetLastError());
|
2008-10-17 00:28:47 +00:00
|
|
|
|
|
|
|
SetLastError(0xE000BEEF);
|
|
|
|
ret = GetTextFaceW(hDC, -1, Buffer);
|
|
|
|
TEST(ret == 0);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() == %ld\n", GetLastError());
|
2008-10-17 00:28:47 +00:00
|
|
|
|
|
|
|
DeleteDC(hDC);
|
2010-08-24 13:54:10 +00:00
|
|
|
}
|
2008-10-16 20:16:38 +00:00
|
|
|
|
2010-08-24 13:54:10 +00:00
|
|
|
START_TEST(GetTextFace)
|
|
|
|
{
|
|
|
|
Test_GetTextFace();
|
2008-10-16 20:16:38 +00:00
|
|
|
}
|
2010-08-24 13:54:10 +00:00
|
|
|
|