gdiplus: Handle StringFormatFlagsNoWrap in GdipMeasureString.
[wine] / dlls / gdiplus / tests / image.c
1 /*
2  * Unit test suite for images
3  *
4  * Copyright (C) 2007 Google (Evan Stade)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "windows.h"
22 #include "gdiplus.h"
23 #include "wine/test.h"
24
25 #define expect(expected, got) ok(((UINT)got) == ((UINT)expected), "Expected %.8x, got %.8x\n", (UINT)expected, (UINT)got)
26
27 static void test_Scan0()
28 {
29     GpBitmap *bm;
30     GpStatus stat;
31     BYTE buff[360];
32
33     bm = NULL;
34     stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, NULL, &bm);
35     expect(Ok, stat);
36     ok(NULL != bm, "Expected bitmap to be initialized\n");
37     GdipDisposeImage((GpImage*)bm);
38
39     bm = (GpBitmap*)0xdeadbeef;
40     stat = GdipCreateBitmapFromScan0(10, -10, 10, PixelFormat24bppRGB, NULL, &bm);
41     expect(InvalidParameter, stat);
42
43     expect(NULL, bm);
44
45     bm = (GpBitmap*)0xdeadbeef;
46     stat = GdipCreateBitmapFromScan0(-10, 10, 10, PixelFormat24bppRGB, NULL, &bm);
47     expect(InvalidParameter, stat);
48
49     expect(NULL, bm);
50
51     bm = (GpBitmap*)0xdeadbeef;
52     stat = GdipCreateBitmapFromScan0(10, 0, 10, PixelFormat24bppRGB, NULL, &bm);
53     expect(InvalidParameter, stat);
54
55     expect(NULL, bm);
56
57     bm = NULL;
58     stat = GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB, buff, &bm);
59     expect(Ok, stat);
60     ok(NULL != bm, "Expected bitmap to be initialized\n");
61     GdipDisposeImage((GpImage*)bm);
62
63     bm = (GpBitmap*) 0xdeadbeef;
64     stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, buff, &bm);
65     expect(InvalidParameter, stat);
66     expect(NULL, bm);
67
68     bm = (GpBitmap*)0xdeadbeef;
69     stat = GdipCreateBitmapFromScan0(10, 10, 0, PixelFormat24bppRGB, buff, &bm);
70     expect(InvalidParameter, stat);
71     expect(0xdeadbeef, bm);
72 }
73
74 START_TEST(image)
75 {
76     struct GdiplusStartupInput gdiplusStartupInput;
77     ULONG_PTR gdiplusToken;
78
79     gdiplusStartupInput.GdiplusVersion              = 1;
80     gdiplusStartupInput.DebugEventCallback          = NULL;
81     gdiplusStartupInput.SuppressBackgroundThread    = 0;
82     gdiplusStartupInput.SuppressExternalCodecs      = 0;
83
84     GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
85
86     test_Scan0();
87
88     GdiplusShutdown(gdiplusToken);
89 }