dmime/tests: Add more GetTrack() tests.
[wine.git] / dlls / t2embed / tests / t2embed.c
blob4ffc3daed1286ba8f5dcea2e97b763c1d16ba7f4
1 /*
2 * Copyright 2016 Nikolay Sivov for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "wingdi.h"
24 #include "winuser.h"
25 #include "t2embapi.h"
26 #include "wine/test.h"
28 static int CALLBACK enum_font_proc(ENUMLOGFONTEXA *enumlf, NEWTEXTMETRICEXA *ntm, DWORD type, LPARAM lParam)
30 OUTLINETEXTMETRICA otm;
31 HDC hdc = GetDC(NULL);
32 HFONT hfont, old_font;
33 ULONG status;
34 LONG ret;
36 hfont = CreateFontIndirectA(&enumlf->elfLogFont);
37 old_font = SelectObject(hdc, hfont);
39 otm.otmSize = sizeof(otm);
40 if (GetOutlineTextMetricsA(hdc, otm.otmSize, &otm))
42 ULONG expected = 0xffff;
43 UINT fsType = otm.otmfsType & 0xf;
45 ret = TTGetEmbeddingType(hdc, &status);
46 ok(ret == E_NONE || ret == E_NOTATRUETYPEFONT, "Unexpected return value %#x.\n", ret);
48 if (ret == E_NONE)
50 if (fsType == LICENSE_INSTALLABLE)
51 expected = EMBED_INSTALLABLE;
52 else if (fsType & LICENSE_EDITABLE)
53 expected = EMBED_EDITABLE;
54 else if (fsType & LICENSE_PREVIEWPRINT)
55 expected = EMBED_PREVIEWPRINT;
56 else if (fsType & LICENSE_NOEMBEDDING)
57 expected = EMBED_NOEMBEDDING;
59 ok(expected == status, "%s: status %d, expected %d, fsType %#x\n", enumlf->elfLogFont.lfFaceName, status,
60 expected, otm.otmfsType);
63 else
65 status = 0xdeadbeef;
66 ret = TTGetEmbeddingType(hdc, &status);
67 ok(ret == E_NOTATRUETYPEFONT, "%s: got %d\n", enumlf->elfLogFont.lfFaceName, ret);
68 ok(status == 0xdeadbeef, "%s: got status %d\n", enumlf->elfLogFont.lfFaceName, status);
71 SelectObject(hdc, old_font);
72 DeleteObject(hfont);
73 ReleaseDC(NULL, hdc);
75 return 1;
78 static void test_TTGetEmbeddingType(void)
80 HFONT hfont, old_font;
81 LOGFONTA logfont;
82 ULONG status;
83 LONG ret;
84 HDC hdc;
86 ret = TTGetEmbeddingType(NULL, NULL);
87 ok(ret == E_HDCINVALID, "got %d\n", ret);
89 status = 0xdeadbeef;
90 ret = TTGetEmbeddingType(NULL, &status);
91 ok(ret == E_HDCINVALID, "got %#x\n", ret);
92 ok(status == 0xdeadbeef, "got %u\n", status);
94 status = 0xdeadbeef;
95 ret = TTGetEmbeddingType((HDC)0xdeadbeef, &status);
96 ok(ret == E_NOTATRUETYPEFONT || broken(ret == E_ERRORACCESSINGFONTDATA) /* xp, vista */, "got %#x\n", ret);
97 ok(status == 0xdeadbeef, "got %u\n", status);
99 hdc = CreateCompatibleDC(0);
101 ret = TTGetEmbeddingType(hdc, NULL);
102 ok(ret == E_NOTATRUETYPEFONT, "got %#x\n", ret);
104 status = 0xdeadbeef;
105 ret = TTGetEmbeddingType(hdc, &status);
106 ok(ret == E_NOTATRUETYPEFONT, "got %#x\n", ret);
107 ok(status == 0xdeadbeef, "got %u\n", status);
109 memset(&logfont, 0, sizeof(logfont));
110 logfont.lfHeight = 12;
111 logfont.lfWeight = FW_NORMAL;
112 strcpy(logfont.lfFaceName, "Tahoma");
113 hfont = CreateFontIndirectA(&logfont);
114 ok(hfont != NULL, "got %p\n", hfont);
116 old_font = SelectObject(hdc, hfont);
118 status = 0;
119 ret = TTGetEmbeddingType(hdc, &status);
120 ok(ret == E_NONE, "got %#x\n", ret);
121 ok(status != 0, "got %u\n", status);
123 ret = TTGetEmbeddingType(hdc, NULL);
124 ok(ret == E_PERMISSIONSINVALID, "got %#x\n", ret);
126 SelectObject(hdc, old_font);
127 DeleteObject(hfont);
129 /* repeat for all system fonts */
130 logfont.lfCharSet = DEFAULT_CHARSET;
131 logfont.lfFaceName[0] = 0;
132 EnumFontFamiliesExA(hdc, &logfont, (FONTENUMPROCA)enum_font_proc, 0, 0);
134 DeleteDC(hdc);
137 static void test_TTIsEmbeddingEnabledForFacename(void)
139 BOOL status;
140 LONG ret;
142 ret = TTIsEmbeddingEnabledForFacename(NULL, NULL);
143 ok(ret == E_FACENAMEINVALID, "got %#x\n", ret);
145 status = 123;
146 ret = TTIsEmbeddingEnabledForFacename(NULL, &status);
147 ok(ret == E_FACENAMEINVALID, "got %#x\n", ret);
148 ok(status == 123, "got %d\n", status);
150 ret = TTIsEmbeddingEnabledForFacename("Arial", NULL);
151 ok(ret == E_PBENABLEDINVALID, "got %#x\n", ret);
153 status = 123;
154 ret = TTIsEmbeddingEnabledForFacename("Arial", &status);
155 ok(ret == E_NONE, "got %#x\n", ret);
156 ok(status != 123, "got %d\n", status);
159 static void test_TTIsEmbeddingEnabled(void)
161 HFONT old_font, hfont;
162 LONG ret, status;
163 LOGFONTA logfont;
164 HDC hdc;
166 ret = TTIsEmbeddingEnabled(NULL, NULL);
167 ok(ret == E_HDCINVALID, "got %#x\n", ret);
169 status = 123;
170 ret = TTIsEmbeddingEnabled(NULL, &status);
171 ok(ret == E_HDCINVALID, "got %#x\n", ret);
172 ok(status == 123, "got %d\n", status);
174 hdc = CreateCompatibleDC(0);
176 memset(&logfont, 0, sizeof(logfont));
177 logfont.lfHeight = 12;
178 logfont.lfWeight = FW_NORMAL;
179 strcpy(logfont.lfFaceName, "Tahoma");
180 hfont = CreateFontIndirectA(&logfont);
181 ok(hfont != NULL, "got %p\n", hfont);
183 old_font = SelectObject(hdc, hfont);
185 ret = TTIsEmbeddingEnabled(hdc, NULL);
186 ok(ret == E_PBENABLEDINVALID, "Unexpected return value %#x.\n", ret);
188 status = 123;
189 ret = TTIsEmbeddingEnabled(hdc, &status);
190 ok(ret == E_NONE, "got %#x\n", ret);
191 ok(status != 123, "got %u\n", status);
193 SelectObject(hdc, old_font);
194 DeleteObject(hfont);
195 DeleteDC(hdc);
198 START_TEST(t2embed)
200 test_TTGetEmbeddingType();
201 test_TTIsEmbeddingEnabledForFacename();
202 test_TTIsEmbeddingEnabled();