urlmon: Don't create stgmed_obj for binding to object.
[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(void)
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     if (stat == Ok)
38         GdipDisposeImage((GpImage*)bm);
39
40     bm = (GpBitmap*)0xdeadbeef;
41     stat = GdipCreateBitmapFromScan0(10, -10, 10, PixelFormat24bppRGB, NULL, &bm);
42     expect(InvalidParameter, stat);
43
44     expect(NULL, bm);
45
46     bm = (GpBitmap*)0xdeadbeef;
47     stat = GdipCreateBitmapFromScan0(-10, 10, 10, PixelFormat24bppRGB, NULL, &bm);
48     expect(InvalidParameter, stat);
49
50     expect(NULL, bm);
51
52     bm = (GpBitmap*)0xdeadbeef;
53     stat = GdipCreateBitmapFromScan0(10, 0, 10, PixelFormat24bppRGB, NULL, &bm);
54     expect(InvalidParameter, stat);
55
56     expect(NULL, bm);
57
58     bm = NULL;
59     stat = GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB, buff, &bm);
60     expect(Ok, stat);
61     ok(NULL != bm, "Expected bitmap to be initialized\n");
62     if (stat == Ok)
63         GdipDisposeImage((GpImage*)bm);
64
65     bm = (GpBitmap*) 0xdeadbeef;
66     stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, buff, &bm);
67     expect(InvalidParameter, stat);
68     expect(NULL, bm);
69
70     bm = (GpBitmap*)0xdeadbeef;
71     stat = GdipCreateBitmapFromScan0(10, 10, 0, PixelFormat24bppRGB, buff, &bm);
72     expect(InvalidParameter, stat);
73     expect(0xdeadbeef, bm);
74 }
75
76 START_TEST(image)
77 {
78     struct GdiplusStartupInput gdiplusStartupInput;
79     ULONG_PTR gdiplusToken;
80
81     gdiplusStartupInput.GdiplusVersion              = 1;
82     gdiplusStartupInput.DebugEventCallback          = NULL;
83     gdiplusStartupInput.SuppressBackgroundThread    = 0;
84     gdiplusStartupInput.SuppressExternalCodecs      = 0;
85
86     GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
87
88     test_Scan0();
89
90     GdiplusShutdown(gdiplusToken);
91 }