Commit f860285c authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Add tests for GdipMeasureCharacterRanges.

parent 21109a40
...@@ -2416,6 +2416,11 @@ static void test_string_functions(void) ...@@ -2416,6 +2416,11 @@ static void test_string_functions(void)
const WCHAR teststring[] = {'o','o',' ','o','\n','o',0}; const WCHAR teststring[] = {'o','o',' ','o','\n','o',0};
REAL char_width, char_height; REAL char_width, char_height;
INT codepointsfitted, linesfilled; INT codepointsfitted, linesfilled;
GpStringFormat *format;
CharacterRange ranges[3] = {{0, 1}, {1, 3}, {5, 1}};
GpRegion *regions[4] = {0};
BOOL region_isempty[4];
int i;
ok(hdc != NULL, "Expected HDC to be initialized\n"); ok(hdc != NULL, "Expected HDC to be initialized\n");
status = GdipCreateFromHDC(hdc, &graphics); status = GdipCreateFromHDC(hdc, &graphics);
...@@ -2439,6 +2444,9 @@ static void test_string_functions(void) ...@@ -2439,6 +2444,9 @@ static void test_string_functions(void)
status = GdipCreateSolidFill(color, (GpSolidFill**)&brush); status = GdipCreateSolidFill(color, (GpSolidFill**)&brush);
expect(Ok, status); expect(Ok, status);
status = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
expect(Ok, status);
rc.X = 0; rc.X = 0;
rc.Y = 0; rc.Y = 0;
rc.Width = 100.0; rc.Width = 100.0;
...@@ -2548,6 +2556,78 @@ static void test_string_functions(void) ...@@ -2548,6 +2556,78 @@ static void test_string_functions(void)
expect(6, codepointsfitted); expect(6, codepointsfitted);
todo_wine expect(4, linesfilled); todo_wine expect(4, linesfilled);
status = GdipSetStringFormatMeasurableCharacterRanges(format, 3, ranges);
expect(Ok, status);
rc.Width = 100.0;
for (i=0; i<4; i++)
{
status = GdipCreateRegion(&regions[i]);
expect(Ok, status);
}
status = GdipMeasureCharacterRanges(NULL, teststring, 6, font, &rc, format, 3, regions);
expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, NULL, 6, font, &rc, format, 3, regions);
expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, teststring, 6, NULL, &rc, format, 3, regions);
expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, NULL, format, 3, regions);
expect(InvalidParameter, status);
if (0)
{
/* Crashes on Windows XP */
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, NULL, 3, regions);
expect(InvalidParameter, status);
}
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, NULL);
expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 2, regions);
todo_wine expect(InvalidParameter, status);
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 4, regions);
todo_wine expect(Ok, status);
for (i=0; i<4; i++)
{
status = GdipIsEmptyRegion(regions[i], graphics, &region_isempty[i]);
expect(Ok, status);
}
ok(!region_isempty[0], "region shouldn't be empty\n");
ok(!region_isempty[1], "region shouldn't be empty\n");
ok(!region_isempty[2], "region shouldn't be empty\n");
ok(!region_isempty[3], "region shouldn't be empty\n");
/* Cut off everything after the first space, and the second line. */
rc.Width = char_bounds.Width + char_width * 2.5;
rc.Height = char_bounds.Height + char_height * 0.5;
status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, regions);
todo_wine expect(Ok, status);
for (i=0; i<4; i++)
{
status = GdipIsEmptyRegion(regions[i], graphics, &region_isempty[i]);
expect(Ok, status);
}
ok(!region_isempty[0], "region shouldn't be empty\n");
ok(!region_isempty[1], "region shouldn't be empty\n");
todo_wine ok(region_isempty[2], "region should be empty\n");
ok(!region_isempty[3], "region shouldn't be empty\n");
for (i=0; i<4; i++)
GdipDeleteRegion(regions[i]);
GdipDeleteStringFormat(format);
GdipDeleteBrush(brush); GdipDeleteBrush(brush);
GdipDeleteFont(font); GdipDeleteFont(font);
GdipDeleteFontFamily(family); GdipDeleteFontFamily(family);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment