2007-07-14 02:51:41 +02:00
|
|
|
/*
|
|
|
|
* Unit test suite for graphics objects
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Google (Evan Stade)
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "windows.h"
|
|
|
|
#include "gdiplus.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
|
2007-07-14 02:51:45 +02:00
|
|
|
#define TABLE_LEN (23)
|
2007-07-14 02:51:41 +02:00
|
|
|
|
2007-08-29 21:42:28 +02:00
|
|
|
static void test_constructor_destructor(void)
|
2007-07-14 02:51:41 +02:00
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
stat = GdipCreateFromHDC(NULL, &graphics);
|
|
|
|
expect(OutOfMemory, stat);
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
|
|
|
|
stat = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
|
|
|
stat = GdipCreateFromHWND(NULL, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
2008-05-09 14:40:41 +02:00
|
|
|
stat = GdipCreateFromHWNDICM(NULL, &graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
stat = GdipDeleteGraphics(graphics);
|
|
|
|
expect(Ok, stat);
|
|
|
|
|
2007-07-14 02:51:41 +02:00
|
|
|
stat = GdipDeleteGraphics(NULL);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2007-07-14 02:51:45 +02:00
|
|
|
typedef struct node{
|
|
|
|
GraphicsState data;
|
|
|
|
struct node * next;
|
|
|
|
} node;
|
|
|
|
|
|
|
|
/* Linked list prepend function. */
|
|
|
|
static void log_state(GraphicsState data, node ** log)
|
|
|
|
{
|
|
|
|
node * new_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(node));
|
|
|
|
|
|
|
|
new_entry->data = data;
|
|
|
|
new_entry->next = *log;
|
|
|
|
*log = new_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Checks if there are duplicates in the list, and frees it. */
|
|
|
|
static void check_no_duplicates(node * log)
|
|
|
|
{
|
|
|
|
INT dups = 0;
|
|
|
|
node * temp = NULL;
|
2008-04-22 01:15:58 +02:00
|
|
|
node * temp2 = NULL;
|
|
|
|
node * orig = log;
|
2007-07-14 02:51:45 +02:00
|
|
|
|
|
|
|
if(!log)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
do{
|
|
|
|
temp = log;
|
2008-04-22 01:15:58 +02:00
|
|
|
while((temp = temp->next)){
|
|
|
|
if(log->data == temp->data){
|
2007-07-14 02:51:45 +02:00
|
|
|
dups++;
|
2008-04-22 01:15:58 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(dups > 0)
|
|
|
|
break;
|
|
|
|
}
|
2007-07-14 02:51:45 +02:00
|
|
|
}while((log = log->next));
|
|
|
|
|
2008-04-22 01:15:58 +02:00
|
|
|
temp = orig;
|
|
|
|
do{
|
|
|
|
temp2 = temp->next;
|
|
|
|
HeapFree(GetProcessHeap(), 0, temp);
|
|
|
|
temp = temp2;
|
|
|
|
}while(temp);
|
2007-07-14 02:51:45 +02:00
|
|
|
|
|
|
|
end:
|
|
|
|
expect(0, dups);
|
|
|
|
}
|
|
|
|
|
2007-08-29 21:42:28 +02:00
|
|
|
static void test_save_restore(void)
|
2007-07-14 02:51:45 +02:00
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GraphicsState state_a, state_b, state_c;
|
|
|
|
InterpolationMode mode;
|
|
|
|
GpGraphics *graphics1, *graphics2;
|
|
|
|
node * state_log = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
2008-04-22 01:08:47 +02:00
|
|
|
state_a = state_b = state_c = 0xdeadbeef;
|
2007-07-14 02:51:45 +02:00
|
|
|
|
|
|
|
/* Invalid saving. */
|
|
|
|
GdipCreateFromHDC(hdc, &graphics1);
|
|
|
|
stat = GdipSaveGraphics(graphics1, NULL);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
stat = GdipSaveGraphics(NULL, &state_a);
|
|
|
|
expect(InvalidParameter, stat);
|
|
|
|
GdipDeleteGraphics(graphics1);
|
|
|
|
|
|
|
|
log_state(state_a, &state_log);
|
|
|
|
|
|
|
|
/* Basic save/restore. */
|
|
|
|
GdipCreateFromHDC(hdc, &graphics1);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
|
|
|
|
stat = GdipSaveGraphics(graphics1, &state_a);
|
2008-11-24 10:22:39 +01:00
|
|
|
expect(Ok, stat);
|
2007-07-14 02:51:45 +02:00
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
|
|
|
|
stat = GdipRestoreGraphics(graphics1, state_a);
|
2008-11-24 10:22:39 +01:00
|
|
|
expect(Ok, stat);
|
2007-07-14 02:51:45 +02:00
|
|
|
GdipGetInterpolationMode(graphics1, &mode);
|
|
|
|
todo_wine
|
|
|
|
expect(InterpolationModeBilinear, mode);
|
|
|
|
GdipDeleteGraphics(graphics1);
|
|
|
|
|
|
|
|
log_state(state_a, &state_log);
|
|
|
|
|
|
|
|
/* Restoring garbage doesn't affect saves. */
|
|
|
|
GdipCreateFromHDC(hdc, &graphics1);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
|
|
|
|
GdipSaveGraphics(graphics1, &state_a);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
|
|
|
|
GdipSaveGraphics(graphics1, &state_b);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
|
|
|
|
stat = GdipRestoreGraphics(graphics1, 0xdeadbeef);
|
2008-11-24 10:22:39 +01:00
|
|
|
expect(Ok, stat);
|
2007-07-14 02:51:45 +02:00
|
|
|
GdipRestoreGraphics(graphics1, state_b);
|
|
|
|
GdipGetInterpolationMode(graphics1, &mode);
|
|
|
|
todo_wine
|
|
|
|
expect(InterpolationModeBicubic, mode);
|
|
|
|
GdipRestoreGraphics(graphics1, state_a);
|
|
|
|
GdipGetInterpolationMode(graphics1, &mode);
|
|
|
|
todo_wine
|
|
|
|
expect(InterpolationModeBilinear, mode);
|
|
|
|
GdipDeleteGraphics(graphics1);
|
|
|
|
|
|
|
|
log_state(state_a, &state_log);
|
|
|
|
log_state(state_b, &state_log);
|
|
|
|
|
|
|
|
/* Restoring older state invalidates newer saves (but not older saves). */
|
|
|
|
GdipCreateFromHDC(hdc, &graphics1);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
|
|
|
|
GdipSaveGraphics(graphics1, &state_a);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
|
|
|
|
GdipSaveGraphics(graphics1, &state_b);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
|
|
|
|
GdipSaveGraphics(graphics1, &state_c);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeHighQualityBilinear);
|
|
|
|
GdipRestoreGraphics(graphics1, state_b);
|
|
|
|
GdipGetInterpolationMode(graphics1, &mode);
|
|
|
|
todo_wine
|
|
|
|
expect(InterpolationModeBicubic, mode);
|
|
|
|
GdipRestoreGraphics(graphics1, state_c);
|
|
|
|
GdipGetInterpolationMode(graphics1, &mode);
|
|
|
|
todo_wine
|
|
|
|
expect(InterpolationModeBicubic, mode);
|
|
|
|
GdipRestoreGraphics(graphics1, state_a);
|
|
|
|
GdipGetInterpolationMode(graphics1, &mode);
|
|
|
|
todo_wine
|
|
|
|
expect(InterpolationModeBilinear, mode);
|
|
|
|
GdipDeleteGraphics(graphics1);
|
|
|
|
|
|
|
|
log_state(state_a, &state_log);
|
|
|
|
log_state(state_b, &state_log);
|
|
|
|
log_state(state_c, &state_log);
|
|
|
|
|
|
|
|
/* Restoring older save from one graphics object does not invalidate
|
|
|
|
* newer save from other graphics object. */
|
|
|
|
GdipCreateFromHDC(hdc, &graphics1);
|
|
|
|
GdipCreateFromHDC(hdc, &graphics2);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
|
|
|
|
GdipSaveGraphics(graphics1, &state_a);
|
|
|
|
GdipSetInterpolationMode(graphics2, InterpolationModeBicubic);
|
|
|
|
GdipSaveGraphics(graphics2, &state_b);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
|
|
|
|
GdipSetInterpolationMode(graphics2, InterpolationModeNearestNeighbor);
|
|
|
|
GdipRestoreGraphics(graphics1, state_a);
|
|
|
|
GdipGetInterpolationMode(graphics1, &mode);
|
|
|
|
todo_wine
|
|
|
|
expect(InterpolationModeBilinear, mode);
|
|
|
|
GdipRestoreGraphics(graphics2, state_b);
|
|
|
|
GdipGetInterpolationMode(graphics2, &mode);
|
|
|
|
todo_wine
|
|
|
|
expect(InterpolationModeBicubic, mode);
|
|
|
|
GdipDeleteGraphics(graphics1);
|
|
|
|
GdipDeleteGraphics(graphics2);
|
|
|
|
|
|
|
|
/* You can't restore a state to a graphics object that didn't save it. */
|
|
|
|
GdipCreateFromHDC(hdc, &graphics1);
|
|
|
|
GdipCreateFromHDC(hdc, &graphics2);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
|
|
|
|
GdipSaveGraphics(graphics1, &state_a);
|
|
|
|
GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
|
|
|
|
GdipSetInterpolationMode(graphics2, InterpolationModeNearestNeighbor);
|
|
|
|
GdipRestoreGraphics(graphics2, state_a);
|
|
|
|
GdipGetInterpolationMode(graphics2, &mode);
|
|
|
|
expect(InterpolationModeNearestNeighbor, mode);
|
|
|
|
GdipDeleteGraphics(graphics1);
|
|
|
|
GdipDeleteGraphics(graphics2);
|
|
|
|
|
|
|
|
log_state(state_a, &state_log);
|
|
|
|
|
|
|
|
/* The same state value should never be returned twice. */
|
|
|
|
todo_wine
|
|
|
|
check_no_duplicates(state_log);
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-02-26 06:06:27 +01:00
|
|
|
static void test_GdipDrawArc(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
GpPen *pen = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
/* make a graphics object and pen object */
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(hdc != NULL, "Expected HDC to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(graphics != NULL, "Expected graphics to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(pen != NULL, "Expected pen to be initialized\n");
|
|
|
|
|
|
|
|
/* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
|
|
|
|
status = GdipDrawArc(NULL, NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawArc(graphics, NULL, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawArc(NULL, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawArc(graphics, pen, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
/* successful case */
|
|
|
|
status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
GdipDeletePen(pen);
|
2008-08-24 12:44:56 +02:00
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
|
2008-02-26 06:06:27 +01:00
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-02-26 06:02:59 +01:00
|
|
|
static void test_GdipDrawArcI(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
GpPen *pen = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
/* make a graphics object and pen object */
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(hdc != NULL, "Expected HDC to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(graphics != NULL, "Expected graphics to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(pen != NULL, "Expected pen to be initialized\n");
|
|
|
|
|
|
|
|
/* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
|
|
|
|
status = GdipDrawArcI(NULL, NULL, 0, 0, 0, 0, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawArcI(graphics, NULL, 0, 0, 1, 1, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawArcI(NULL, pen, 0, 0, 1, 1, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawArcI(graphics, pen, 0, 0, 1, 0, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawArcI(graphics, pen, 0, 0, 0, 1, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
/* successful case */
|
|
|
|
status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0, 0);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
GdipDeletePen(pen);
|
2008-08-24 12:44:56 +02:00
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
|
2008-02-26 06:02:59 +01:00
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-02-26 06:00:43 +01:00
|
|
|
static void test_GdipDrawBezierI(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
GpPen *pen = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
/* make a graphics object and pen object */
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(hdc != NULL, "Expected HDC to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(graphics != NULL, "Expected graphics to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(pen != NULL, "Expected pen to be initialized\n");
|
|
|
|
|
|
|
|
/* InvalidParameter cases: null graphics, null pen */
|
|
|
|
status = GdipDrawBezierI(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawBezierI(graphics, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawBezierI(NULL, pen, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
/* successful case */
|
|
|
|
status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
GdipDeletePen(pen);
|
2008-08-24 12:44:56 +02:00
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
|
2008-02-26 06:00:43 +01:00
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-02-26 06:08:01 +01:00
|
|
|
static void test_GdipDrawLineI(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
GpPen *pen = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
/* make a graphics object and pen object */
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(hdc != NULL, "Expected HDC to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(graphics != NULL, "Expected graphics to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(pen != NULL, "Expected pen to be initialized\n");
|
|
|
|
|
|
|
|
/* InvalidParameter cases: null graphics, null pen */
|
|
|
|
status = GdipDrawLineI(NULL, NULL, 0, 0, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawLineI(graphics, NULL, 0, 0, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawLineI(NULL, pen, 0, 0, 0, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
/* successful case */
|
|
|
|
status = GdipDrawLineI(graphics, pen, 0, 0, 0, 0);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
GdipDeletePen(pen);
|
2008-08-24 12:44:56 +02:00
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
|
2008-02-26 06:08:01 +01:00
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-02-29 13:58:39 +01:00
|
|
|
static void test_GdipDrawLinesI(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
GpPen *pen = NULL;
|
|
|
|
GpPoint *ptf = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
/* make a graphics object and pen object */
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(hdc != NULL, "Expected HDC to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(graphics != NULL, "Expected graphics to be initialized\n");
|
|
|
|
|
|
|
|
status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(pen != NULL, "Expected pen to be initialized\n");
|
|
|
|
|
|
|
|
/* make some arbitrary valid points*/
|
|
|
|
ptf = GdipAlloc(2 * sizeof(GpPointF));
|
|
|
|
|
|
|
|
ptf[0].X = 1;
|
|
|
|
ptf[0].Y = 1;
|
|
|
|
|
|
|
|
ptf[1].X = 2;
|
|
|
|
ptf[1].Y = 2;
|
|
|
|
|
|
|
|
/* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
|
|
|
|
status = GdipDrawLinesI(NULL, NULL, NULL, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawLinesI(graphics, pen, ptf, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawLinesI(graphics, NULL, ptf, 2);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipDrawLinesI(NULL, pen, ptf, 2);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
/* successful case */
|
|
|
|
status = GdipDrawLinesI(graphics, pen, ptf, 2);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
GdipFree(ptf);
|
|
|
|
GdipDeletePen(pen);
|
2008-08-24 12:44:56 +02:00
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
|
2008-02-29 13:58:39 +01:00
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-08-24 12:45:14 +02:00
|
|
|
static void test_Get_Release_DC(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
GpPen *pen;
|
|
|
|
GpSolidFill *brush;
|
|
|
|
GpPath *path;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
HDC retdc;
|
|
|
|
REAL r;
|
|
|
|
CompositingQuality quality;
|
|
|
|
CompositingMode compmode;
|
|
|
|
InterpolationMode intmode;
|
|
|
|
GpMatrix *m;
|
|
|
|
GpRegion *region;
|
|
|
|
GpUnit unit;
|
|
|
|
PixelOffsetMode offsetmode;
|
|
|
|
SmoothingMode smoothmode;
|
|
|
|
TextRenderingHint texthint;
|
|
|
|
GpPointF ptf[5];
|
|
|
|
GpPoint pt[5];
|
|
|
|
GpRectF rectf[2];
|
|
|
|
GpRect rect[2];
|
2008-08-27 21:30:59 +02:00
|
|
|
GpRegion *clip;
|
2008-08-24 12:45:14 +02:00
|
|
|
INT i;
|
2008-09-26 20:34:39 +02:00
|
|
|
BOOL res;
|
2008-12-11 08:32:43 +01:00
|
|
|
ARGB color = 0x00000000;
|
2008-08-24 12:45:14 +02:00
|
|
|
|
|
|
|
pt[0].X = 10;
|
|
|
|
pt[0].Y = 10;
|
|
|
|
pt[1].X = 20;
|
|
|
|
pt[1].Y = 15;
|
|
|
|
pt[2].X = 40;
|
|
|
|
pt[2].Y = 80;
|
|
|
|
pt[3].X = -20;
|
|
|
|
pt[3].Y = 20;
|
|
|
|
pt[4].X = 50;
|
|
|
|
pt[4].Y = 110;
|
|
|
|
|
|
|
|
for(i = 0; i < 5;i++){
|
|
|
|
ptf[i].X = (REAL)pt[i].X;
|
|
|
|
ptf[i].Y = (REAL)pt[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
rect[0].X = 0;
|
|
|
|
rect[0].Y = 0;
|
|
|
|
rect[0].Width = 50;
|
|
|
|
rect[0].Height = 70;
|
|
|
|
rect[1].X = 0;
|
|
|
|
rect[1].Y = 0;
|
|
|
|
rect[1].Width = 10;
|
|
|
|
rect[1].Height = 20;
|
|
|
|
|
|
|
|
for(i = 0; i < 2;i++){
|
|
|
|
rectf[i].X = (REAL)rect[i].X;
|
|
|
|
rectf[i].Y = (REAL)rect[i].Y;
|
|
|
|
rectf[i].Height = (REAL)rect[i].Height;
|
|
|
|
rectf[i].Width = (REAL)rect[i].Width;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdipCreateMatrix(&m);
|
|
|
|
GdipCreateRegion(®ion);
|
|
|
|
GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
|
|
|
|
GdipCreatePath(FillModeAlternate, &path);
|
2008-08-27 21:30:59 +02:00
|
|
|
GdipCreateRegion(&clip);
|
2008-08-24 12:45:14 +02:00
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
ok(graphics != NULL, "Expected graphics to be initialized\n");
|
|
|
|
status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
/* NULL arguments */
|
|
|
|
status = GdipGetDC(NULL, NULL);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipGetDC(graphics, NULL);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipGetDC(NULL, &retdc);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
2008-09-01 17:02:32 +02:00
|
|
|
status = GdipReleaseDC(NULL, NULL);
|
2008-08-24 12:45:14 +02:00
|
|
|
expect(InvalidParameter, status);
|
2008-09-01 17:02:32 +02:00
|
|
|
status = GdipReleaseDC(graphics, NULL);
|
2008-08-24 12:45:14 +02:00
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipReleaseDC(NULL, (HDC)0xdeadbeef);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
2008-08-24 12:45:18 +02:00
|
|
|
/* Release without Get */
|
|
|
|
status = GdipReleaseDC(graphics, hdc);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
2008-08-24 12:45:14 +02:00
|
|
|
retdc = NULL;
|
|
|
|
status = GdipGetDC(graphics, &retdc);
|
2008-08-24 12:45:18 +02:00
|
|
|
expect(Ok, status);
|
|
|
|
ok(retdc == hdc, "Invalid HDC returned\n");
|
2008-08-24 12:45:14 +02:00
|
|
|
/* call it once more */
|
|
|
|
status = GdipGetDC(graphics, &retdc);
|
2008-08-24 12:45:18 +02:00
|
|
|
expect(ObjectBusy, status);
|
2008-08-24 12:45:14 +02:00
|
|
|
|
|
|
|
/* try all Graphics calls here */
|
|
|
|
status = Ok;
|
|
|
|
status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0.0, 0.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawBezier(graphics, pen, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawBeziers(graphics, pen, ptf, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawBeziersI(graphics, pen, pt, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawClosedCurve(graphics, pen, ptf, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawClosedCurveI(graphics, pen, pt, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawClosedCurve2(graphics, pen, ptf, 5, 1.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawClosedCurve2I(graphics, pen, pt, 5, 1.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawCurve(graphics, pen, ptf, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawCurveI(graphics, pen, pt, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawCurve2(graphics, pen, ptf, 5, 1.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawCurve2I(graphics, pen, pt, 5, 1.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawEllipse(graphics, pen, 0.0, 0.0, 100.0, 50.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawEllipseI(graphics, pen, 0, 0, 100, 50);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
/* GdipDrawImage/GdipDrawImageI */
|
|
|
|
/* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
|
|
|
|
/* GdipDrawImageRectRect/GdipDrawImageRectRectI */
|
|
|
|
/* GdipDrawImageRect/GdipDrawImageRectI */
|
|
|
|
status = GdipDrawLine(graphics, pen, 0.0, 0.0, 100.0, 200.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawLineI(graphics, pen, 0, 0, 100, 200);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawLines(graphics, pen, ptf, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawLinesI(graphics, pen, pt, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawPath(graphics, pen, path);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawPie(graphics, pen, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawPieI(graphics, pen, 0, 0, 100, 100, 0.0, 90.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawRectangle(graphics, pen, 0.0, 0.0, 100.0, 300.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawRectangleI(graphics, pen, 0, 0, 100, 300);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawRectangles(graphics, pen, rectf, 2);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawRectanglesI(graphics, pen, rect, 2);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
/* GdipDrawString */
|
|
|
|
status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, ptf, 5, 1.0, FillModeAlternate);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, pt, 5, 1.0, FillModeAlternate);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillEllipse(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillEllipseI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillPath(graphics, (GpBrush*)brush, path);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillPie(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillPieI(graphics, (GpBrush*)brush, 0, 0, 100, 100, 0.0, 15.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillPolygon(graphics, (GpBrush*)brush, ptf, 5, FillModeAlternate);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillPolygonI(graphics, (GpBrush*)brush, pt, 5, FillModeAlternate);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillPolygon2(graphics, (GpBrush*)brush, ptf, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillPolygon2I(graphics, (GpBrush*)brush, pt, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillRectangle(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillRectangles(graphics, (GpBrush*)brush, rectf, 2);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillRectanglesI(graphics, (GpBrush*)brush, rect, 2);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFillRegion(graphics, (GpBrush*)brush, region);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipFlush(graphics, FlushIntentionFlush);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetCompositingMode(graphics, &compmode);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetCompositingQuality(graphics, &quality);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetInterpolationMode(graphics, &intmode);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-12-11 08:32:43 +01:00
|
|
|
status = GdipGetNearestColor(graphics, &color);
|
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetPageScale(graphics, &r);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetPageUnit(graphics, &unit);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetPixelOffsetMode(graphics, &offsetmode);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetSmoothingMode(graphics, &smoothmode);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetTextRenderingHint(graphics, &texthint);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetWorldTransform(graphics, m);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-09-05 11:56:10 +02:00
|
|
|
status = GdipGraphicsClear(graphics, 0xdeadbeef);
|
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-09-26 20:34:39 +02:00
|
|
|
status = GdipIsVisiblePoint(graphics, 0.0, 0.0, &res);
|
|
|
|
expect(ObjectBusy, status); status = Ok;
|
|
|
|
status = GdipIsVisiblePointI(graphics, 0, 0, &res);
|
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
/* GdipMeasureCharacterRanges */
|
|
|
|
/* GdipMeasureString */
|
2008-08-28 15:34:22 +02:00
|
|
|
status = GdipResetClip(graphics);
|
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipResetWorldTransform(graphics);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
/* GdipRestoreGraphics */
|
|
|
|
status = GdipRotateWorldTransform(graphics, 15.0, MatrixOrderPrepend);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
/* GdipSaveGraphics */
|
|
|
|
status = GdipScaleWorldTransform(graphics, 1.0, 1.0, MatrixOrderPrepend);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetCompositingMode(graphics, CompositingModeSourceOver);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetCompositingQuality(graphics, CompositingQualityDefault);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetInterpolationMode(graphics, InterpolationModeDefault);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetPageScale(graphics, 1.0);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetPageUnit(graphics, UnitWorld);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetPixelOffsetMode(graphics, PixelOffsetModeDefault);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetSmoothingMode(graphics, SmoothingModeDefault);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetTextRenderingHint(graphics, TextRenderingHintSystemDefault);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetWorldTransform(graphics, m);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipTranslateWorldTransform(graphics, 0.0, 0.0, MatrixOrderPrepend);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-09-26 20:18:09 +02:00
|
|
|
status = GdipSetClipPath(graphics, path, CombineModeReplace);
|
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-09-25 08:41:15 +02:00
|
|
|
status = GdipSetClipRect(graphics, 0.0, 0.0, 10.0, 10.0, CombineModeReplace);
|
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipSetClipRectI(graphics, 0, 0, 10, 10, CombineModeReplace);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-27 21:30:59 +02:00
|
|
|
status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
|
|
|
|
expect(ObjectBusy, status);
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawPolygon(graphics, pen, ptf, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipDrawPolygonI(graphics, pen, pt, 5);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetDpiX(graphics, &r);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipGetDpiY(graphics, &r);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-24 12:45:14 +02:00
|
|
|
status = GdipMultiplyWorldTransform(graphics, m, MatrixOrderPrepend);
|
|
|
|
status = GdipGetClip(graphics, region);
|
2008-08-24 12:45:23 +02:00
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-25 23:58:42 +02:00
|
|
|
status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 5);
|
|
|
|
expect(ObjectBusy, status); status = Ok;
|
2008-08-25 23:58:33 +02:00
|
|
|
/* try to delete before release */
|
|
|
|
status = GdipDeleteGraphics(graphics);
|
|
|
|
expect(ObjectBusy, status);
|
2008-08-24 12:45:14 +02:00
|
|
|
|
|
|
|
status = GdipReleaseDC(graphics, retdc);
|
2008-08-24 12:45:18 +02:00
|
|
|
expect(Ok, status);
|
2008-08-24 12:45:14 +02:00
|
|
|
|
|
|
|
GdipDeletePen(pen);
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
|
|
|
|
GdipDeletePath(path);
|
|
|
|
GdipDeleteBrush((GpBrush*)brush);
|
|
|
|
GdipDeleteRegion(region);
|
|
|
|
GdipDeleteMatrix(m);
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-08-25 23:58:42 +02:00
|
|
|
static void test_transformpoints(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
GpPointF ptf[5];
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
for(i = 0; i < 5; i++){
|
|
|
|
ptf[i].X = 200.0 + i * 50.0 * (i % 2);
|
|
|
|
ptf[i].Y = 200.0 + i * 50.0 * !(i % 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NULL arguments */
|
|
|
|
status = GdipTransformPoints(NULL, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 0);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, -1);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-08-27 21:30:59 +02:00
|
|
|
static void test_get_set_clip(void)
|
2008-08-25 23:58:45 +02:00
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
GpRegion *clip;
|
2008-08-25 23:58:49 +02:00
|
|
|
GpRectF rect;
|
2008-08-25 23:58:45 +02:00
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
2008-08-25 23:58:49 +02:00
|
|
|
rect.X = rect.Y = 0.0;
|
|
|
|
rect.Height = rect.Width = 100.0;
|
|
|
|
|
|
|
|
status = GdipCreateRegionRect(&rect, &clip);
|
2008-08-25 23:58:45 +02:00
|
|
|
|
|
|
|
/* NULL arguments */
|
|
|
|
status = GdipGetClip(NULL, NULL);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipGetClip(graphics, NULL);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipGetClip(NULL, clip);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
2008-08-27 21:30:59 +02:00
|
|
|
status = GdipSetClipRegion(NULL, NULL, CombineModeReplace);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipSetClipRegion(graphics, NULL, CombineModeReplace);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
2008-09-26 20:18:09 +02:00
|
|
|
status = GdipSetClipPath(NULL, NULL, CombineModeReplace);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipSetClipPath(graphics, NULL, CombineModeReplace);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
2008-08-25 23:58:45 +02:00
|
|
|
res = FALSE;
|
|
|
|
status = GdipGetClip(graphics, clip);
|
2008-08-27 00:03:27 +02:00
|
|
|
expect(Ok, status);
|
2008-08-25 23:58:45 +02:00
|
|
|
status = GdipIsInfiniteRegion(clip, graphics, &res);
|
2008-08-25 23:58:49 +02:00
|
|
|
expect(Ok, status);
|
2008-08-27 00:03:27 +02:00
|
|
|
expect(TRUE, res);
|
2008-08-25 23:58:45 +02:00
|
|
|
|
2008-08-28 15:34:22 +02:00
|
|
|
/* remains infinite after reset */
|
|
|
|
res = FALSE;
|
|
|
|
status = GdipResetClip(graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
status = GdipGetClip(graphics, clip);
|
|
|
|
expect(Ok, status);
|
|
|
|
status = GdipIsInfiniteRegion(clip, graphics, &res);
|
|
|
|
expect(Ok, status);
|
|
|
|
expect(TRUE, res);
|
|
|
|
|
|
|
|
/* set to empty and then reset to infinite */
|
|
|
|
status = GdipSetEmpty(clip);
|
|
|
|
expect(Ok, status);
|
|
|
|
status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
status = GdipGetClip(graphics, clip);
|
|
|
|
expect(Ok, status);
|
|
|
|
res = FALSE;
|
|
|
|
status = GdipIsEmptyRegion(clip, graphics, &res);
|
|
|
|
expect(Ok, status);
|
|
|
|
expect(TRUE, res);
|
|
|
|
status = GdipResetClip(graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
status = GdipGetClip(graphics, clip);
|
|
|
|
expect(Ok, status);
|
|
|
|
res = FALSE;
|
|
|
|
status = GdipIsInfiniteRegion(clip, graphics, &res);
|
|
|
|
expect(Ok, status);
|
|
|
|
expect(TRUE, res);
|
|
|
|
|
2008-08-25 23:58:45 +02:00
|
|
|
GdipDeleteRegion(clip);
|
|
|
|
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-08-28 15:49:41 +02:00
|
|
|
static void test_isempty(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
GpGraphics *graphics = NULL;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
GpRegion *clip;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
status = GdipCreateRegion(&clip);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
/* NULL */
|
|
|
|
status = GdipIsClipEmpty(NULL, NULL);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipIsClipEmpty(graphics, NULL);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipIsClipEmpty(NULL, &res);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
/* default is infinite */
|
|
|
|
res = TRUE;
|
|
|
|
status = GdipIsClipEmpty(graphics, &res);
|
|
|
|
expect(Ok, status);
|
|
|
|
expect(FALSE, res);
|
|
|
|
|
|
|
|
GdipDeleteRegion(clip);
|
|
|
|
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-09-05 11:56:10 +02:00
|
|
|
static void test_clear(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
|
|
|
|
status = GdipGraphicsClear(NULL, 0xdeadbeef);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
}
|
|
|
|
|
2008-11-09 12:32:26 +01:00
|
|
|
static void test_textcontrast(void)
|
|
|
|
{
|
|
|
|
GpStatus status;
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
GpGraphics *graphics;
|
|
|
|
UINT contrast;
|
|
|
|
|
|
|
|
status = GdipGetTextContrast(NULL, NULL);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
|
|
|
|
status = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
expect(Ok, status);
|
|
|
|
|
|
|
|
status = GdipGetTextContrast(graphics, NULL);
|
|
|
|
expect(InvalidParameter, status);
|
|
|
|
status = GdipGetTextContrast(graphics, &contrast);
|
|
|
|
expect(4, contrast);
|
|
|
|
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2007-07-14 02:51:41 +02:00
|
|
|
START_TEST(graphics)
|
|
|
|
{
|
|
|
|
struct GdiplusStartupInput gdiplusStartupInput;
|
|
|
|
ULONG_PTR gdiplusToken;
|
|
|
|
|
|
|
|
gdiplusStartupInput.GdiplusVersion = 1;
|
|
|
|
gdiplusStartupInput.DebugEventCallback = NULL;
|
|
|
|
gdiplusStartupInput.SuppressBackgroundThread = 0;
|
|
|
|
gdiplusStartupInput.SuppressExternalCodecs = 0;
|
|
|
|
|
|
|
|
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
|
|
|
|
|
|
|
|
test_constructor_destructor();
|
2007-07-14 02:51:45 +02:00
|
|
|
test_save_restore();
|
2008-02-26 06:00:43 +01:00
|
|
|
test_GdipDrawBezierI();
|
2008-02-26 06:06:27 +01:00
|
|
|
test_GdipDrawArc();
|
2008-02-26 06:02:59 +01:00
|
|
|
test_GdipDrawArcI();
|
2008-02-26 06:08:01 +01:00
|
|
|
test_GdipDrawLineI();
|
2008-02-29 13:58:39 +01:00
|
|
|
test_GdipDrawLinesI();
|
2008-08-24 12:45:14 +02:00
|
|
|
test_Get_Release_DC();
|
2008-08-25 23:58:42 +02:00
|
|
|
test_transformpoints();
|
2008-08-27 21:30:59 +02:00
|
|
|
test_get_set_clip();
|
2008-08-28 15:49:41 +02:00
|
|
|
test_isempty();
|
2008-09-05 11:56:10 +02:00
|
|
|
test_clear();
|
2008-11-09 12:32:26 +01:00
|
|
|
test_textcontrast();
|
2007-07-14 02:51:41 +02:00
|
|
|
|
|
|
|
GdiplusShutdown(gdiplusToken);
|
|
|
|
}
|