dmime: Remove DECLSPEC_HIDDEN usage.
[wine.git] / dlls / t2embed / tests / t2embed.c
blobaa4e1ca2cc83b2bbb409cd9d8ee8a5bcf4b9635b
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 "winnls.h"
24 #include "wingdi.h"
25 #include "winuser.h"
26 #include "t2embapi.h"
27 #include "wine/test.h"
29 static int CALLBACK enum_font_proc(ENUMLOGFONTEXA *enumlf, NEWTEXTMETRICEXA *ntm, DWORD type, LPARAM lParam)
31 OUTLINETEXTMETRICA otm;
32 HDC hdc = GetDC(NULL);
33 HFONT hfont, old_font;
34 ULONG status;
35 LONG ret;
37 hfont = CreateFontIndirectA(&enumlf->elfLogFont);
38 old_font = SelectObject(hdc, hfont);
40 otm.otmSize = sizeof(otm);
41 if (GetOutlineTextMetricsA(hdc, otm.otmSize, &otm))
43 ULONG expected = 0xffff;
44 UINT fsType = otm.otmfsType & 0xf;
46 ret = TTGetEmbeddingType(hdc, &status);
47 ok(ret == E_NONE || ret == E_NOTATRUETYPEFONT, "Unexpected return value %#lx.\n", ret);
49 if (ret == E_NONE)
51 if (fsType == LICENSE_INSTALLABLE)
52 expected = EMBED_INSTALLABLE;
53 else if (fsType & LICENSE_EDITABLE)
54 expected = EMBED_EDITABLE;
55 else if (fsType & LICENSE_PREVIEWPRINT)
56 expected = EMBED_PREVIEWPRINT;
57 else if (fsType & LICENSE_NOEMBEDDING)
58 expected = EMBED_NOEMBEDDING;
60 ok(expected == status, "%s: status %ld, expected %ld, fsType %#x\n", enumlf->elfLogFont.lfFaceName, status,
61 expected, otm.otmfsType);
64 else
66 status = 0xdeadbeef;
67 ret = TTGetEmbeddingType(hdc, &status);
68 ok(ret == E_NOTATRUETYPEFONT, "%s: got %ld.\n", enumlf->elfLogFont.lfFaceName, ret);
69 ok(status == 0xdeadbeef, "%s: got status %#lx.\n", enumlf->elfLogFont.lfFaceName, status);
72 SelectObject(hdc, old_font);
73 DeleteObject(hfont);
74 ReleaseDC(NULL, hdc);
76 return 1;
79 static void test_TTGetEmbeddingType(void)
81 HFONT hfont, old_font;
82 LOGFONTA logfont;
83 ULONG status;
84 LONG ret;
85 HDC hdc;
87 ret = TTGetEmbeddingType(NULL, NULL);
88 ok(ret == E_HDCINVALID, "Unexpected retval %#lx.\n", ret);
90 status = 0xdeadbeef;
91 ret = TTGetEmbeddingType(NULL, &status);
92 ok(ret == E_HDCINVALID, "Unexpected retval %#lx.\n", ret);
93 ok(status == 0xdeadbeef, "Unexpected status %#lx.\n", status);
95 status = 0xdeadbeef;
96 ret = TTGetEmbeddingType((HDC)0xdeadbeef, &status);
97 ok(ret == E_NOTATRUETYPEFONT || broken(ret == E_ERRORACCESSINGFONTDATA) /* xp, vista */,
98 "Unexpected retval %#lx.\n", ret);
99 ok(status == 0xdeadbeef, "Unexpected status %#lx.\n", status);
101 hdc = CreateCompatibleDC(0);
103 ret = TTGetEmbeddingType(hdc, NULL);
104 ok(ret == E_NOTATRUETYPEFONT || (ret == E_PERMISSIONSINVALID && GetACP() == CP_UTF8),
105 "Unexpected retval %#lx.\n", ret);
107 status = 0xdeadbeef;
108 ret = TTGetEmbeddingType(hdc, &status);
109 ok(ret == E_NOTATRUETYPEFONT || (ret == E_NONE && GetACP() == CP_UTF8),
110 "Unexpected retval %#lx.\n", ret);
111 ok(status == 0xdeadbeef || (status == EMBED_EDITABLE && GetACP() == CP_UTF8),
112 "Unexpected status %#lx.\n", status);
114 memset(&logfont, 0, sizeof(logfont));
115 logfont.lfHeight = 12;
116 logfont.lfWeight = FW_NORMAL;
117 strcpy(logfont.lfFaceName, "Tahoma");
118 hfont = CreateFontIndirectA(&logfont);
119 ok(hfont != NULL, "got %p\n", hfont);
121 old_font = SelectObject(hdc, hfont);
123 status = 0;
124 ret = TTGetEmbeddingType(hdc, &status);
125 ok(ret == E_NONE, "Unexpected retval %#lx.\n", ret);
126 ok(status != 0, "Unexpected status %lu.\n", status);
128 ret = TTGetEmbeddingType(hdc, NULL);
129 ok(ret == E_PERMISSIONSINVALID, "Unexpected retval %#lx.\n", ret);
131 SelectObject(hdc, old_font);
132 DeleteObject(hfont);
134 /* repeat for all system fonts */
135 logfont.lfCharSet = DEFAULT_CHARSET;
136 logfont.lfFaceName[0] = 0;
137 EnumFontFamiliesExA(hdc, &logfont, (FONTENUMPROCA)enum_font_proc, 0, 0);
139 DeleteDC(hdc);
142 static void test_TTIsEmbeddingEnabledForFacename(void)
144 BOOL status;
145 LONG ret;
147 ret = TTIsEmbeddingEnabledForFacename(NULL, NULL);
148 ok(ret == E_FACENAMEINVALID, "Unexpected retval %#lx.\n", ret);
150 status = 123;
151 ret = TTIsEmbeddingEnabledForFacename(NULL, &status);
152 ok(ret == E_FACENAMEINVALID, "Unexpected retval %#lx.\n", ret);
153 ok(status == 123, "got %d\n", status);
155 ret = TTIsEmbeddingEnabledForFacename("Arial", NULL);
156 ok(ret == E_PBENABLEDINVALID, "Unexpected retval %#lx.\n", ret);
158 status = 123;
159 ret = TTIsEmbeddingEnabledForFacename("Arial", &status);
160 ok(ret == E_NONE, "Unexpected retval %#lx.\n", ret);
161 ok(status != 123, "got %d\n", status);
164 static void test_TTIsEmbeddingEnabled(void)
166 HFONT old_font, hfont;
167 LOGFONTA logfont;
168 BOOL status;
169 LONG ret;
170 HDC hdc;
172 ret = TTIsEmbeddingEnabled(NULL, NULL);
173 ok(ret == E_HDCINVALID, "Unexpected retval %#lx.\n", ret);
175 status = 123;
176 ret = TTIsEmbeddingEnabled(NULL, &status);
177 ok(ret == E_HDCINVALID, "Unexpected retval %#lx.\n", ret);
178 ok(status == 123, "Unexpected status %d.\n", status);
180 hdc = CreateCompatibleDC(0);
182 memset(&logfont, 0, sizeof(logfont));
183 logfont.lfHeight = 12;
184 logfont.lfWeight = FW_NORMAL;
185 strcpy(logfont.lfFaceName, "Tahoma");
186 hfont = CreateFontIndirectA(&logfont);
187 ok(hfont != NULL, "got %p\n", hfont);
189 old_font = SelectObject(hdc, hfont);
191 ret = TTIsEmbeddingEnabled(hdc, NULL);
192 ok(ret == E_PBENABLEDINVALID, "Unexpected retval %#lx.\n", ret);
194 status = 123;
195 ret = TTIsEmbeddingEnabled(hdc, &status);
196 ok(ret == E_NONE, "Unexpected retval %#lx.\n", ret);
197 ok(status != 123, "Unexpected status %d.\n", status);
199 SelectObject(hdc, old_font);
200 DeleteObject(hfont);
201 DeleteDC(hdc);
204 START_TEST(t2embed)
206 test_TTGetEmbeddingType();
207 test_TTIsEmbeddingEnabledForFacename();
208 test_TTIsEmbeddingEnabled();