advapi32: Remove a useless macro.
[wine] / dlls / usp10 / tests / usp10.c
1 /*
2  * Tests for usp10 dll
3  *
4  * Copyright 2006 Jeff Latimer
5  * Copyright 2006 Hans Leidekker
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  *
21  * Notes:
22  * Uniscribe allows for processing of complex scripts such as joining
23  * and filtering characters and bi-directional text with custom line breaks.
24  */
25
26 #include <assert.h>
27 #include <stdio.h>
28
29 #include <wine/test.h>
30 #include <winbase.h>
31 #include <wingdi.h>
32 #include <winuser.h>
33 #include <winerror.h>
34 #include <winnls.h>
35 #include <usp10.h>
36
37 static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
38 {
39     HRESULT         hr;
40     int             iMaxProps;
41     const SCRIPT_PROPERTIES **ppSp;
42
43     int             cInChars;
44     int             cMaxItems;
45     SCRIPT_ITEM     pItem[255];
46     int             pcItems;
47     WCHAR           TestItem1[] = {'T', 'e', 's', 't', 'a', 0}; 
48     WCHAR           TestItem2[] = {'T', 'e', 's', 't', 'b', 0}; 
49     WCHAR           TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0}; 
50     WCHAR           TestItem4[] = {'T', 'e', 's', 't', 'c',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
51     WCHAR           TestItem5[] = {0x0684,'T','e','s','t','c',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0}; 
52
53     SCRIPT_CACHE    psc;
54     int             cChars;
55     int             cMaxGlyphs;
56     unsigned short  pwOutGlyphs1[256];
57     unsigned short  pwOutGlyphs2[256];
58     unsigned short  pwLogClust[256];
59     SCRIPT_VISATTR  psva[256];
60     int             pcGlyphs;
61     int             piAdvance[256];
62     GOFFSET         pGoffset[256];
63     ABC             pABC[256];
64     LOGFONTA        lf;
65     HFONT           zfont;
66     int             cnt;
67
68
69     lstrcpyA(lf.lfFaceName, "Symbol");
70     lf.lfHeight = 10;
71     lf.lfItalic = 0;
72     lf.lfEscapement = 0;
73     lf.lfOrientation = 0;
74     lf.lfUnderline = 0;
75     lf.lfStrikeOut = 0;
76     lf.lfWeight = 3;
77     lf.lfWidth = 10;
78
79     zfont = (HFONT) SelectObject(hdc, CreateFontIndirectA(&lf));
80
81     /* Start testing usp10 functions                                                         */
82     /* This test determines that the pointer returned by ScriptGetProperties is valid
83      * by checking a known value in the table                                                */
84     hr = ScriptGetProperties(&ppSp, &iMaxProps);
85     trace("number of script properties %d\n", iMaxProps);
86     ok (iMaxProps > 0, "Number of scripts returned should not be 0\n"); 
87     if  (iMaxProps > 0)
88          ok( ppSp[5]->langid == 9, "Langid[5] not = to 9\n"); /* Check a known value to ensure   */
89                                                               /* ptrs work                       */
90
91
92     /* This set of tests are to check that the various edits in ScriptIemize work           */
93     cInChars = 5;                                        /* Length of test without NULL     */
94     cMaxItems = 1;                                       /* Check threshold value           */
95     hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
96     ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.  Was %d\n",
97         cMaxItems);
98     cInChars = 5;
99     cMaxItems = 255;
100     hr = ScriptItemize(NULL, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
101     ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
102
103     cInChars = 5;
104     cMaxItems = 255;
105     hr = ScriptItemize(TestItem1, 0, cMaxItems, NULL, NULL, pItem, &pcItems);
106     ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
107
108     cInChars = 5;
109     cMaxItems = 255;
110     hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, NULL, &pcItems);
111     ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
112
113     /* This is a valid test that will cause parsing to take place                             */
114     cInChars = 5;
115     cMaxItems = 255;
116     hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
117     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
118     /*  This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
119      *  returned.                                                                             */
120     ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
121     if (pcItems > 0)
122         ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
123             "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
124             pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
125
126     /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
127      * ie. ScriptItemize has succeeded and that pItem has been set                            */
128     cInChars = 5;
129     cMaxItems = 255;
130     if (hr == 0) {
131         psc = NULL;                                   /* must be null on first call           */
132         cChars = cInChars;
133         cMaxGlyphs = cInChars;
134         hr = ScriptShape(NULL, &psc, TestItem1, cChars,
135                          cMaxGlyphs, &pItem[0].a,
136                          pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
137         ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr);
138         cMaxGlyphs = 4;
139         hr = ScriptShape(hdc, &psc, TestItem1, cChars,
140                          cMaxGlyphs, &pItem[0].a,
141                          pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
142         ok (hr == E_OUTOFMEMORY, "If not enough output area cChars (%d) is > than CMaxGlyphs "
143                                  "(%d) but not E_OUTOFMEMORY\n",
144                                  cChars, cMaxGlyphs);
145         cMaxGlyphs = 256;
146         hr = ScriptShape(hdc, &psc, TestItem1, cChars,
147                          cMaxGlyphs, &pItem[0].a,
148                          pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
149         ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
150         ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
151         ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
152         if (hr ==0) {
153             hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
154                              pGoffset, pABC);
155             ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
156             hr = ScriptPlace(NULL, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
157                              pGoffset, pABC);
158             ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
159             for (cnt=0; cnt < pcGlyphs; cnt++)
160                 pwOutGlyphs[cnt] = pwOutGlyphs1[cnt];                 /* Send to next function */
161         }
162
163         /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation   *
164          * takes place if fNoGlyphIndex is set.                                                     */
165
166         cInChars = 5;
167         cMaxItems = 255;
168         hr = ScriptItemize(TestItem2, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
169         ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
170         /*  This test is for the intertrim operation of ScriptItemize where only one SCRIPT_ITEM is *
171          *  returned.                                                                               */
172         ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
173                             "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
174                              pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
175         /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue                    */
176         if (hr == 0) {
177              cChars = cInChars;
178              cMaxGlyphs = 256;
179              pItem[0].a.fNoGlyphIndex = 1;                /* say no translate                     */
180              hr = ScriptShape(NULL, &psc, TestItem2, cChars,
181                               cMaxGlyphs, &pItem[0].a,
182                               pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
183              ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr);
184              ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
185              ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
186              ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
187              for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
188              ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
189                            cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
190              if (hr ==0) {
191                  hr = ScriptPlace(hdc, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
192                                   pGoffset, pABC);
193                  ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
194              }
195         }
196         hr = ScriptFreeCache( &psc);
197         ok (!psc, "psc is not null after ScriptFreeCache\n");
198
199     }
200
201     /* This is a valid test that will cause parsing to take place and create 3 script_items   */
202     cInChars = (sizeof(TestItem3)/2)-1;
203     cMaxItems = 255;
204     hr = ScriptItemize(TestItem3, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
205     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
206     if  (hr == 0)
207         {
208         ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
209         if (pcItems > 2)
210         {
211             ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
212                 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
213                 pItem[0].iCharPos, pItem[1].iCharPos);
214             ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
215                 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
216                 pItem[1].iCharPos, pItem[2].iCharPos);
217             ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
218                 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
219                 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
220         }
221         hr = ScriptFreeCache( &psc);
222         ok (!psc, "psc is not null after ScriptFreeCache\n");
223     }
224
225     /* This is a valid test that will cause parsing to take place and create 3 script_items   */
226     cInChars = (sizeof(TestItem4)/2)-1;
227     cMaxItems = 255;
228     hr = ScriptItemize(TestItem4, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
229     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
230     if  (hr == 0)
231         {
232         ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
233         if (pcItems > 2)
234         {
235             ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
236                 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
237                 pItem[0].iCharPos, pItem[1].iCharPos);
238             ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
239                 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
240                 pItem[1].iCharPos, pItem[2].iCharPos);
241             ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
242                 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
243                 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
244         }
245         hr = ScriptFreeCache( &psc);
246         ok (!psc, "psc is not null after ScriptFreeCache\n");
247     }
248
249     /*
250      * This test is for when the first unicode character requires bidi support
251      */ 
252     cInChars = (sizeof(TestItem5)-1)/sizeof(WCHAR);
253     hr = ScriptItemize(TestItem5, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
254     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
255     ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
256     ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n", 
257                                        pItem[0].a.s.uBidiLevel);
258 }
259
260 static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
261 {
262     HRESULT         hr;
263     SCRIPT_CACHE    psc = NULL;
264     int             cInChars;
265     int             cChars;
266     unsigned short  pwOutGlyphs3[256];
267     WCHAR           TestItem1[] = {'T', 'e', 's', 't', 'a', 0}; 
268     DWORD           dwFlags;
269     int             cnt;
270
271     /*  Check to make sure that SCRIPT_CACHE gets allocated ok                     */
272     dwFlags = 0;
273     cInChars = cChars = 5;
274     /* Some sanity checks for ScriptGetCMap */
275
276     hr = ScriptGetCMap(NULL, NULL, NULL, 0, 0, NULL);
277     ok( hr == E_INVALIDARG, "(NULL,NULL,NULL,0,0,NULL), "
278                             "expected E_INVALIDARG, got %08x\n", hr);
279
280     hr = ScriptGetCMap(NULL, NULL, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
281     ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
282                             "expected E_INVALIDARG, got %08x\n", hr);
283
284     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
285     psc = NULL;
286     hr = ScriptGetCMap(NULL, &psc, NULL, 0, 0, NULL);
287     ok( hr == E_PENDING, "(NULL,&psc,NULL,0,0NULL), expected E_PENDING, "
288                          "got %08x\n", hr);
289     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
290
291     /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
292     psc = NULL;
293     hr = ScriptGetCMap(hdc, &psc, NULL, 0, 0, NULL);
294     ok( hr == S_OK, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
295                     "got %08x\n", hr);
296     ok( psc != NULL, "ScritpGetCMap expected psc to be not NULL\n");
297
298     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
299     psc = NULL;
300     hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
301     ok( hr == E_PENDING, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr);
302     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
303     /*  Check to see if the results are the same as those returned by ScriptShape  */
304     hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
305     ok (hr == 0, "ScriptGetCMap should return 0 not (%08x)\n", hr);
306     ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
307     for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
308     ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
309                          cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
310         
311     hr = ScriptFreeCache( &psc);
312     ok (!psc, "psc is not null after ScriptFreeCache\n");
313
314 }
315
316 static void test_ScriptGetFontProperties(HDC hdc)
317 {
318     HRESULT         hr;
319     SCRIPT_CACHE    psc,old_psc;
320     SCRIPT_FONTPROPERTIES sfp;
321
322     /* Some sanity checks for ScriptGetFontProperties */
323
324     hr = ScriptGetFontProperties(NULL,NULL,NULL);
325     ok( hr == E_INVALIDARG, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
326
327     hr = ScriptGetFontProperties(NULL,NULL,&sfp);
328     ok( hr == E_INVALIDARG, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
329
330     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
331     psc = NULL;
332     hr = ScriptGetFontProperties(NULL,&psc,NULL);
333     ok( hr == E_INVALIDARG, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
334     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
335
336     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
337     psc = NULL;
338     hr = ScriptGetFontProperties(NULL,&psc,&sfp);
339     ok( hr == E_PENDING, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr);
340     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
341
342     hr = ScriptGetFontProperties(hdc,NULL,NULL);
343     ok( hr == E_INVALIDARG, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
344
345     hr = ScriptGetFontProperties(hdc,NULL,&sfp);
346     ok( hr == E_INVALIDARG, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
347
348     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
349     psc = NULL;
350     hr = ScriptGetFontProperties(hdc,&psc,NULL);
351     ok( hr == E_INVALIDARG, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
352     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
353
354     /* Pass an uninitialized sfp */
355     psc = NULL;
356     hr = ScriptGetFontProperties(hdc,&psc,&sfp);
357     ok( hr == E_INVALIDARG, "(hdc,&psc,&sfp) partly uninitialized, expected E_INVALIDARG, got %08x\n", hr);
358     ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
359     ScriptFreeCache(&psc);
360     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
361
362     /* Give it the correct cBytes, we don't care about what's coming back */
363     sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
364     psc = NULL;
365     hr = ScriptGetFontProperties(hdc,&psc,&sfp);
366     ok( hr == S_OK, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr);
367     ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
368
369     /* Save the psc pointer */
370     old_psc = psc;
371     /* Now a NULL hdc again */
372     hr = ScriptGetFontProperties(NULL,&psc,&sfp);
373     ok( hr == S_OK, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr);
374     ok( psc == old_psc, "Expected psc not to be changed, was %p is now %p\n", old_psc, psc);
375     ScriptFreeCache(&psc);
376     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
377 }
378
379 static void test_ScriptTextOut(HDC hdc)
380 {
381     HRESULT         hr;
382
383     int             cInChars;
384     int             cMaxItems;
385     SCRIPT_ITEM     pItem[255];
386     int             pcItems;
387     WCHAR           TestItem1[] = {'T', 'e', 's', 't', 'a', 0}; 
388
389     SCRIPT_CACHE    psc;
390     int             cChars;
391     int             cMaxGlyphs;
392     unsigned short  pwOutGlyphs1[256];
393     WORD            pwLogClust[256];
394     SCRIPT_VISATTR  psva[256];
395     int             pcGlyphs;
396     int             piAdvance[256];
397     GOFFSET         pGoffset[256];
398     ABC             pABC[256];
399     RECT            rect;
400     int             piX;
401     int             iCP = 1;
402     BOOL            fTrailing = FALSE;
403     SCRIPT_LOGATTR  *psla;
404     SCRIPT_LOGATTR  sla[256];
405
406     /* This is a valid test that will cause parsing to take place                             */
407     cInChars = 5;
408     cMaxItems = 255;
409     hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
410     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
411     /*  This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
412      *  returned.                                                                             */
413     ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
414     if (pcItems > 0)
415         ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
416             "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
417             pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
418
419     /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
420      * ie. ScriptItemize has succeeded and that pItem has been set                            */
421     cInChars = 5;
422     cMaxItems = 255;
423     if (hr == 0) {
424         psc = NULL;                                   /* must be null on first call           */
425         cChars = cInChars;
426         cMaxGlyphs = cInChars;
427         cMaxGlyphs = 256;
428         hr = ScriptShape(hdc, &psc, TestItem1, cChars,
429                          cMaxGlyphs, &pItem[0].a,
430                          pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
431         ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
432         ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
433         ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
434         if (hr ==0) {
435             /* Note hdc is needed as glyph info is not yet in psc                  */
436             hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
437                              pGoffset, pABC);
438             ok (hr == 0, "Should return 0 not (%08x)\n", hr);
439             ScriptFreeCache(&psc);              /* Get rid of psc for next test set */
440             ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
441
442             hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
443             ok (hr == E_INVALIDARG, "Should return 0 not (%08x)\n", hr);
444
445             hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
446                                piAdvance, NULL, pGoffset);
447             ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
448                                     "expected E_INVALIDARG, got %08x\n", hr);
449
450             /* Set psc to NULL, to be able to check if a pointer is returned in psc */
451             psc = NULL;
452             hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0,
453                                NULL, NULL, NULL);
454             ok( hr == E_INVALIDARG, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
455                                     "got %08x\n", hr);
456             ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
457
458             /* Set psc to NULL, to be able to check if a pointer is returned in psc
459              * hdc is required for this one rather than the usual optional          */
460             psc = NULL;
461             hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
462                                piAdvance, NULL, pGoffset);
463             ok( hr == E_INVALIDARG, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr);
464             ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
465
466             /* Set that is gets a psc and that returns 0 status */
467             hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
468                                piAdvance, NULL, pGoffset);
469             ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
470             ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
471
472             /* Test Rect Rgn is acceptable */
473             rect.top = 10;
474             rect.bottom = 20;
475             rect.left = 10;
476             rect.right = 40;
477             hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
478                                piAdvance, NULL, pGoffset);
479             ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
480             ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
481
482             iCP = 1;
483             hr = ScriptCPtoX(iCP, fTrailing, cChars, pcGlyphs, (const WORD *) &pwLogClust,
484                             (const SCRIPT_VISATTR *) &psva, (const int *)&piAdvance, &pItem[0].a, &piX);
485             ok(hr == S_OK, "ScriptCPtoX Stub should return S_OK not %08x\n", hr);
486
487             psla = (SCRIPT_LOGATTR *)&sla;
488             hr = ScriptBreak(TestItem1, cChars, &pItem[0].a, psla);
489             ok(hr == S_OK, "ScriptBreak Stub should return S_OK not %08x\n", hr);
490
491             /* Clean up and go   */
492             ScriptFreeCache(&psc);
493             ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
494         }
495     }
496 }
497
498 static void test_ScriptXtoX(void)
499 /****************************************************************************************
500  *  This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
501  ****************************************************************************************/
502 {
503     int iX, iCP;
504     int cChars;
505     int cGlyphs;
506     WORD pwLogClust[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
507     SCRIPT_VISATTR psva[10];
508     int piAdvance[10] = {200, 190, 210, 180, 170, 204, 189, 195, 212, 203};
509     SCRIPT_ANALYSIS psa;
510     int piCP, piX;
511     int piTrailing;
512     BOOL fTrailing;
513     HRESULT hr;
514
515     iX = -1;
516     cChars = 10;
517     cGlyphs = 10;
518     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
519     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
520     ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
521     ok(piTrailing == TRUE, "Negative iX should return piTrailing=TRUE not %d\n", piTrailing);
522     iX = 1954;
523     cChars = 10;
524     cGlyphs = 10;
525     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
526     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
527     ok(piCP == 10, "Excessive iX should return piCP=10 not %d\n", piCP);
528     ok(piTrailing == FALSE, "Excessive iX should return piTrailing=FALSE not %d\n", piTrailing);
529     iX = 779;
530     cChars = 10;
531     cGlyphs = 10;
532     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
533     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
534     ok(piCP == 3, "iX=%d should return piCP=3 not %d\n", iX, piCP);
535     ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
536     iX = 780;
537     cChars = 10;
538     cGlyphs = 10;
539     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
540     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
541     ok(piCP == 3, "iX=%d should return piCP=3 not %d\n", iX, piCP);
542     ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
543     iX = 868;
544     cChars = 10;
545     cGlyphs = 10;
546     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
547     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
548     ok(piCP == 4, "iX=%d should return piCP=4 not %d\n", iX, piCP);
549
550     iX = 0;
551     cChars = 10;
552     cGlyphs = 10;
553     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
554     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
555     ok(piCP == 0, "iX=%d should return piCP=0 not %d\n", iX, piCP);
556     iX = 195;
557     cChars = 10;
558     cGlyphs = 10;
559     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
560     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
561     ok(piCP == 0, "iX=%d should return piCP=0 not %d\n", iX, piCP);
562     iX = 196;
563     cChars = 10;
564     cGlyphs = 10;
565     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
566     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
567     ok(piCP == 1, "iX=%d should return piCP=1 not %d\n", iX, piCP);
568
569     iCP=5;
570     fTrailing = FALSE;
571     cChars = 10;
572     cGlyphs = 10;
573     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
574     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
575     ok(piX == 976, "iCP=%d should return piX=976 not %d\n", iCP, piX);
576     iCP=5;
577     fTrailing = TRUE;
578     cChars = 10;
579     cGlyphs = 10;
580     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
581     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
582     ok(piX == 1171, "iCP=%d should return piX=1171 not %d\n", iCP, piX);   
583     iCP=6;
584     fTrailing = FALSE;
585     cChars = 10;
586     cGlyphs = 10;
587     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
588     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
589     ok(piX == 1171, "iCP=%d should return piX=1171 not %d\n", iCP, piX);
590     iCP=11;
591     fTrailing = FALSE;
592     cChars = 10;
593     cGlyphs = 10;
594     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
595     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
596     ok(piX == 1953, "iCP=%d should return piX=1953 not %d\n", iCP, piX);
597     iCP=11;
598     fTrailing = TRUE;
599     cChars = 10;
600     cGlyphs = 10;
601     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
602     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
603     ok(piX == 1953, "iCP=%d should return piX=1953 not %d\n", iCP, piX); 
604
605 }
606
607 static void test_ScriptString(HDC hdc)
608 {
609 /*******************************************************************************************
610  *
611  * This set of tests are for the string functions of uniscribe.  The ScriptStringAnalyse
612  * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer.  This
613  * memory if freed by ScriptStringFree.  There needs to be a valid hdc for this as
614  * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
615  *
616  */
617
618     HRESULT         hr;
619     WCHAR           teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
620     int             len = (sizeof(teststr) / sizeof(WCHAR)) - 1;
621     int             Glyphs = len * 2 + 16;
622     int             Charset;
623     DWORD           Flags = SSA_GLYPHS;
624     int             ReqWidth = 100;
625     SCRIPT_CONTROL  Control;
626     SCRIPT_STATE    State;
627     const int       Dx[5] = {10, 10, 10, 10, 10};
628     SCRIPT_TABDEF   Tabdef;
629     const BYTE      InClass = 0;
630     SCRIPT_STRING_ANALYSIS ssa = NULL;
631
632     int             X = 10; 
633     int             Y = 100;
634     UINT            Options = 0; 
635     const RECT      rc = {0, 50, 100, 100}; 
636     int             MinSel = 0;
637     int             MaxSel = 0;
638     BOOL            Disabled = FALSE;
639     const int      *clip_len;
640     UINT           *order, i;
641
642
643     Charset = -1;     /* this flag indicates unicode input */
644     /* Test without hdc to get E_PENDING */
645     hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
646                              ReqWidth, &Control, &State, Dx, &Tabdef,
647                              &InClass, &ssa);
648     ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
649
650     /* test with hdc, this should be a valid test  */
651     hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
652                               ReqWidth, &Control, &State, Dx, &Tabdef,
653                               &InClass, &ssa);
654     ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
655
656     /* test makes sure that a call with a valid pssa still works */
657     hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
658                               ReqWidth, &Control, &State, Dx, &Tabdef,
659                               &InClass, &ssa);
660     ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
661     ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
662
663     if (hr == S_OK)
664     {
665         hr = ScriptStringOut(ssa, X, Y, Options, &rc, MinSel, MaxSel, Disabled);
666         ok(hr == S_OK, "ScriptStringOut should return S_OK not %08x\n", hr);
667     }
668
669      clip_len = ScriptString_pcOutChars(ssa);
670      ok(*clip_len == len, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len, len);
671
672      order = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *clip_len * sizeof(UINT));
673      hr = ScriptStringGetOrder(ssa, order);
674      ok(hr == S_OK, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr);
675
676      for (i = 0; i < *clip_len; i++) ok(order[i] == i, "%d: got %d expected %d\n", i, order[i], i);
677      HeapFree(GetProcessHeap(), 0, order);
678
679      hr = ScriptStringFree(&ssa);
680      ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
681 }
682
683 static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
684 {
685 /*****************************************************************************************
686  *
687  * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions.  Due to the
688  * nature of the fonts between Windows and Wine, the test is implemented by generating
689  * values using one one function then checking the output of the second.  In this way
690  * the validity of the functions is established using Windows as a base and confirming
691  * similar behaviour in wine.
692  */
693
694     HRESULT         hr;
695     WCHAR           teststr1[] = {'T', 'e', 's', 't', 'e', '1', '2', ' ', 'a', '\0'};
696     void            *String = (WCHAR *) &teststr1;      /* ScriptStringAnalysis needs void */
697     int             String_len = (sizeof(teststr1)/sizeof(WCHAR))-1;
698     int             Glyphs = String_len * 2 + 16;       /* size of buffer as recommended  */
699     int             Charset = -1;                       /* unicode                        */
700     DWORD           Flags = SSA_GLYPHS;
701     int             ReqWidth = 100;
702     SCRIPT_CONTROL  Control;
703     SCRIPT_STATE    State;
704     SCRIPT_TABDEF   Tabdef;
705     const BYTE      InClass = 0;
706     SCRIPT_STRING_ANALYSIS ssa = NULL;
707
708     int             Ch;                                  /* Character position in string */
709     int             iTrailing;
710     int             Cp;                                  /* Character position in string */
711     int             X;
712     BOOL            fTrailing;
713
714     LOGFONTA        lf;
715     HFONT           zfont;
716
717     lstrcpyA(lf.lfFaceName, "Symbol");
718     lf.lfHeight = 10;
719     lf.lfCharSet = 0;
720     lf.lfItalic = 0;
721     lf.lfEscapement = 0;
722     lf.lfOrientation = 0;
723     lf.lfUnderline = 0;
724     lf.lfStrikeOut = 0;
725     lf.lfWeight = 400;
726     lf.lfWidth = 0;
727     lf.lfPitchAndFamily = 0;
728
729     zfont = (HFONT) SelectObject(hdc, CreateFontIndirectA(&lf));
730
731     /* Test with hdc, this should be a valid test
732      * Here we generrate an SCRIPT_STRING_ANALYSIS that will be used as input to the
733      * following character positions to X and X to character position functions.
734      */
735     hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
736                               ReqWidth, &Control, &State, NULL, &Tabdef,
737                               &InClass, &ssa);
738     ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
739     ok(ssa != NULL, "ScriptStringAnalyse ssa should not be NULL\n");
740     if  (hr == 0)
741     {
742         /*
743          * Loop to generate character positions to provide starting positions for the
744          * ScriptStringCPtoX and ScriptStringXtoCP functions
745          */
746         for (Cp = 0; Cp < String_len; Cp++)
747         {
748             /* The fTrailing flag is used to indicate whether the X being returned is at
749              * the beginning or the end of the character. What happens here is that if
750              * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
751              * returns the beginning of the next character and iTrailing is FALSE.  So for this
752              * loop iTrailing will be FALSE in both cases.
753              */
754             fTrailing = FALSE;
755             hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
756             ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
757             hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
758             ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
759             ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
760             ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n", 
761                                   iTrailing, X);
762             fTrailing = TRUE;
763             hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
764             ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
765             hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
766             ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
767
768             /*
769              * Check that character position returned by ScriptStringXtoCP in Ch matches the
770              * one input to ScriptStringCPtoX.  This means that the Cp to X position and back
771              * again works
772              */
773             ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, X);
774             ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n", 
775                                    iTrailing, X);
776         }
777         /*
778          * This test is to check that if the X position is just inside the trailing edge of the
779          * character then iTrailing will indicate the trailing edge, ie. TRUE
780          */
781         fTrailing = TRUE;
782         Cp = 3;
783         hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
784         ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
785         X--;                                /* put X just inside the trailing edge */
786         hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
787         ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
788         ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
789         ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n", 
790                                   iTrailing, X);
791
792         /*
793          * This test is to check that if the X position is just outside the trailing edge of the
794          * character then iTrailing will indicate the leading edge, ie. FALSE, and Ch will indicate
795          * the next character, ie. Cp + 1 
796          */
797         fTrailing = TRUE;
798         Cp = 3;
799         hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
800         ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
801         X++;                                /* put X just outside the trailing edge */
802         hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
803         ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
804         ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, X);
805         ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n", 
806                                   iTrailing, X);
807
808         /*
809          * This test is to check that if the X position is just outside the leading edge of the
810          * character then iTrailing will indicate the trailing edge, ie. TRUE, and Ch will indicate
811          * the next character down , ie. Cp - 1 
812          */
813         fTrailing = FALSE;
814         Cp = 3;
815         hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
816         ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
817         X--;                                /* put X just outside the leading edge */
818         hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
819         ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
820         ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, X);
821         ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n", 
822                                   iTrailing, X);
823
824         /*
825          * Cleanup the the SSA for the next round of tests
826          */
827         hr = ScriptStringFree(&ssa);
828         ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
829
830         /*
831          * Test to see that exceeding the number of chars returns E_INVALIDARG.  First
832          * generate an SSA for the subsequent tests.
833          */
834         hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
835                                   ReqWidth, &Control, &State, NULL, &Tabdef,
836                                   &InClass, &ssa);
837         ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
838
839         /*
840          * When ScriptStringCPtoX is called with a character position Cp that exceeds the
841          * string length, return E_INVALIDARG.  This also invalidates the ssa so a 
842          * ScriptStringFree should also fail.
843          */
844         fTrailing = FALSE;
845         Cp = String_len + 1; 
846         hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
847         ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr);
848
849         hr = ScriptStringFree(&ssa);
850         /*
851          * ScriptStringCPtoX should free ssa, hence ScriptStringFree should fail
852          */
853         ok(hr == E_INVALIDARG, "ScriptStringFree should return E_INVALIDARG not %08x\n", hr);
854     }
855 }
856
857 static void test_ScriptCacheGetHeight(HDC hdc)
858 {
859     HRESULT hr;
860     SCRIPT_CACHE sc = NULL;
861     LONG height;
862
863     hr = ScriptCacheGetHeight(NULL, NULL, NULL);
864     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
865
866     hr = ScriptCacheGetHeight(NULL, &sc, NULL);
867     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
868
869     hr = ScriptCacheGetHeight(NULL, &sc, &height);
870     ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
871
872     height = 0;
873
874     hr = ScriptCacheGetHeight(hdc, &sc, &height);
875     ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
876
877     ok(height > 0, "expected height > 0\n");
878 }
879
880 static void test_ScriptGetGlyphABCWidth(HDC hdc)
881 {
882     HRESULT hr;
883     LOGFONTA lf;
884     HFONT hfont;
885     SCRIPT_CACHE sc = NULL;
886     ABC abc;
887
888     memset(&lf, 0, sizeof(lf));
889
890     lstrcpyA(lf.lfFaceName, "Symbol");
891     hfont = CreateFontIndirectA(&lf);
892     hfont = SelectObject(hdc, hfont);
893
894     hr = ScriptGetGlyphABCWidth(NULL, NULL, 'a', NULL);
895     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
896
897     hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', NULL);
898     ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
899
900     if (0) {    /* crashes on WinXP */
901     hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', NULL);
902     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
903     }
904
905     hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', &abc);
906     ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
907 }
908
909 static void test_ScriptLayout(void)
910 {
911     HRESULT hr;
912     static const BYTE levels[][5] =
913     {
914         { 0, 0, 0, 0, 0 },
915         { 1, 1, 1, 1, 1 },
916         { 2, 2, 2, 2, 2 },
917         { 3, 3, 3, 3, 3 },
918     };
919     static const int expect[][5] =
920     {
921         { 0, 1, 2, 3, 4 },
922         { 4, 3, 2, 1, 0 },
923         { 0, 1, 2, 3, 4 },
924         { 4, 3, 2, 1, 0 }
925     };
926     int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
927
928     hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
929     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
930
931     hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL);
932     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
933
934     for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
935     {
936         hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis);
937         ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
938
939         for (j = 0; j < sizeof(levels[i]); j++)
940         {
941             ok(expect[i][j] == vistolog[j],
942                "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
943                i, j, levels[i][j], j, vistolog[j] );
944         }
945
946         for (j = 0; j < sizeof(levels[i]); j++)
947         {
948             ok(expect[i][j] == logtovis[j],
949                "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
950                i, j, levels[i][j], j, logtovis[j] );
951         }
952     }
953 }
954
955 static const struct
956 {
957     LGRPID group;
958     LCID lcid;
959     SCRIPT_DIGITSUBSTITUTE sds;
960     DWORD uDefaultLanguage;
961     DWORD fContextDigits;
962     WORD fDigitSubstitute;
963 }
964 subst_data[] =
965 {
966     { 0x01, 0x00403, { 9, 3, 1, 0 }, 9, 0, 0 },
967     { 0x01, 0x00406, { 9, 6, 1, 0 }, 9, 0, 0 },
968     { 0x01, 0x00407, { 9, 7, 1, 0 }, 9, 0, 0 },
969     { 0x01, 0x00409, { 9, 9, 1, 0 }, 9, 0, 0 },
970     { 0x01, 0x0040a, { 9, 10, 1, 0 }, 9, 0, 0 },
971     { 0x01, 0x0040b, { 9, 11, 1, 0 }, 9, 0, 0 },
972     { 0x01, 0x0040c, { 9, 12, 1, 0 }, 9, 0, 0 },
973     { 0x01, 0x0040f, { 9, 15, 1, 0 }, 9, 0, 0 },
974     { 0x01, 0x00410, { 9, 16, 1, 0 }, 9, 0, 0 },
975     { 0x01, 0x00413, { 9, 19, 1, 0 }, 9, 0, 0 },
976     { 0x01, 0x00414, { 9, 20, 1, 0 }, 9, 0, 0 },
977     { 0x01, 0x00416, { 9, 22, 1, 0 }, 9, 0, 0 },
978     { 0x01, 0x0041d, { 9, 29, 1, 0 }, 9, 0, 0 },
979     { 0x01, 0x00421, { 9, 33, 1, 0 }, 9, 0, 0 },
980     { 0x01, 0x0042d, { 9, 45, 1, 0 }, 9, 0, 0 },
981     { 0x01, 0x00432, { 9, 50, 1, 0 }, 9, 0, 0 },
982     { 0x01, 0x00434, { 9, 52, 1, 0 }, 9, 0, 0 },
983     { 0x01, 0x00435, { 9, 53, 1, 0 }, 9, 0, 0 },
984     { 0x01, 0x00436, { 9, 54, 1, 0 }, 9, 0, 0 },
985     { 0x01, 0x00438, { 9, 56, 1, 0 }, 9, 0, 0 },
986     { 0x01, 0x0043a, { 9, 58, 1, 0 }, 9, 0, 0 },
987     { 0x01, 0x0043b, { 9, 59, 1, 0 }, 9, 0, 0 },
988     { 0x01, 0x0043e, { 9, 62, 1, 0 }, 9, 0, 0 },
989     { 0x01, 0x00441, { 9, 65, 1, 0 }, 9, 0, 0 },
990     { 0x01, 0x00452, { 9, 82, 1, 0 }, 9, 0, 0 },
991     { 0x01, 0x00456, { 9, 86, 1, 0 }, 9, 0, 0 },
992     { 0x01, 0x0046b, { 9, 107, 1, 0 }, 9, 0, 0 },
993     { 0x01, 0x0046c, { 9, 108, 1, 0 }, 9, 0, 0 },
994     { 0x01, 0x00481, { 9, 129, 1, 0 }, 9, 0, 0 },
995     { 0x01, 0x00807, { 9, 7, 1, 0 }, 9, 0, 0 },
996     { 0x01, 0x00809, { 9, 9, 1, 0 }, 9, 0, 0 },
997     { 0x01, 0x0080a, { 9, 10, 1, 0 }, 9, 0, 0 },
998     { 0x01, 0x0080c, { 9, 12, 1, 0 }, 9, 0, 0 },
999     { 0x01, 0x00810, { 9, 16, 1, 0 }, 9, 0, 0 },
1000     { 0x01, 0x00813, { 9, 19, 1, 0 }, 9, 0, 0 },
1001     { 0x01, 0x00814, { 9, 20, 1, 0 }, 9, 0, 0 },
1002     { 0x01, 0x00816, { 9, 22, 1, 0 }, 9, 0, 0 },
1003     { 0x01, 0x0081d, { 9, 29, 1, 0 }, 9, 0, 0 },
1004     { 0x01, 0x0083b, { 9, 59, 1, 0 }, 9, 0, 0 },
1005     { 0x01, 0x0083e, { 9, 62, 1, 0 }, 9, 0, 0 },
1006     { 0x01, 0x0086b, { 9, 107, 1, 0 }, 9, 0, 0 },
1007     { 0x01, 0x00c07, { 9, 7, 1, 0 }, 9, 0, 0 },
1008     { 0x01, 0x00c09, { 9, 9, 1, 0 }, 9, 0, 0 },
1009     { 0x01, 0x00c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1010     { 0x01, 0x00c0c, { 9, 12, 1, 0 }, 9, 0, 0 },
1011     { 0x01, 0x00c3b, { 9, 59, 1, 0 }, 9, 0, 0 },
1012     { 0x01, 0x00c6b, { 9, 107, 1, 0 }, 9, 0, 0 },
1013     { 0x01, 0x01007, { 9, 7, 1, 0 }, 9, 0, 0 },
1014     { 0x01, 0x01009, { 9, 9, 1, 0 }, 9, 0, 0 },
1015     { 0x01, 0x0100a, { 9, 10, 1, 0 }, 9, 0, 0 },
1016     { 0x01, 0x0100c, { 9, 12, 1, 0 }, 9, 0, 0 },
1017     { 0x01, 0x0103b, { 9, 59, 1, 0 }, 9, 0, 0 },
1018     { 0x01, 0x01407, { 9, 7, 1, 0 }, 9, 0, 0 },
1019     { 0x01, 0x01409, { 9, 9, 1, 0 }, 9, 0, 0 },
1020     { 0x01, 0x0140a, { 9, 10, 1, 0 }, 9, 0, 0 },
1021     { 0x01, 0x0140c, { 9, 12, 1, 0 }, 9, 0, 0 },
1022     { 0x01, 0x0143b, { 9, 59, 1, 0 }, 9, 0, 0 },
1023     { 0x01, 0x01809, { 9, 9, 1, 0 }, 9, 0, 0 },
1024     { 0x01, 0x0180a, { 9, 10, 1, 0 }, 9, 0, 0 },
1025     { 0x01, 0x0180c, { 9, 12, 1, 0 }, 9, 0, 0 },
1026     { 0x01, 0x0183b, { 9, 59, 1, 0 }, 9, 0, 0 },
1027     { 0x01, 0x01c09, { 9, 9, 1, 0 }, 9, 0, 0 },
1028     { 0x01, 0x01c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1029     { 0x01, 0x01c3b, { 9, 59, 1, 0 }, 9, 0, 0 },
1030     { 0x01, 0x02009, { 9, 9, 1, 0 }, 9, 0, 0 },
1031     { 0x01, 0x0200a, { 9, 10, 1, 0 }, 9, 0, 0 },
1032     { 0x01, 0x0203b, { 9, 59, 1, 0 }, 9, 0, 0 },
1033     { 0x01, 0x02409, { 9, 9, 1, 0 }, 9, 0, 0 },
1034     { 0x01, 0x0240a, { 9, 10, 1, 0 }, 9, 0, 0 },
1035     { 0x01, 0x0243b, { 9, 59, 1, 0 }, 9, 0, 0 },
1036     { 0x01, 0x02809, { 9, 9, 1, 0 }, 9, 0, 0 },
1037     { 0x01, 0x0280a, { 9, 10, 1, 0 }, 9, 0, 0 },
1038     { 0x01, 0x02c09, { 9, 9, 1, 0 }, 9, 0, 0 },
1039     { 0x01, 0x02c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1040     { 0x01, 0x03009, { 9, 9, 1, 0 }, 9, 0, 0 },
1041     { 0x01, 0x0300a, { 9, 10, 1, 0 }, 9, 0, 0 },
1042     { 0x01, 0x03409, { 9, 9, 1, 0 }, 9, 0, 0 },
1043     { 0x01, 0x0340a, { 9, 10, 1, 0 }, 9, 0, 0 },
1044     { 0x01, 0x0380a, { 9, 10, 1, 0 }, 9, 0, 0 },
1045     { 0x01, 0x03c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1046     { 0x01, 0x0400a, { 9, 10, 1, 0 }, 9, 0, 0 },
1047     { 0x01, 0x0440a, { 9, 10, 1, 0 }, 9, 0, 0 },
1048     { 0x01, 0x0480a, { 9, 10, 1, 0 }, 9, 0, 0 },
1049     { 0x01, 0x04c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1050     { 0x01, 0x0500a, { 9, 10, 1, 0 }, 9, 0, 0 },
1051     { 0x01, 0x10407, { 9, 7, 1, 0 }, 9, 0, 0 },
1052     { 0x02, 0x00405, { 9, 5, 1, 0 }, 9, 0, 0 },
1053     { 0x02, 0x0040e, { 9, 14, 1, 0 }, 9, 0, 0 },
1054     { 0x02, 0x00415, { 9, 21, 1, 0 }, 9, 0, 0 },
1055     { 0x02, 0x00418, { 9, 24, 1, 0 }, 9, 0, 0 },
1056     { 0x02, 0x0041a, { 9, 26, 1, 0 }, 9, 0, 0 },
1057     { 0x02, 0x0041b, { 9, 27, 1, 0 }, 9, 0, 0 },
1058     { 0x02, 0x0041c, { 9, 28, 1, 0 }, 9, 0, 0 },
1059     { 0x02, 0x00424, { 9, 36, 1, 0 }, 9, 0, 0 },
1060     { 0x02, 0x0081a, { 9, 26, 1, 0 }, 9, 0, 0 },
1061     { 0x02, 0x0101a, { 9, 26, 1, 0 }, 9, 0, 0 },
1062     { 0x02, 0x0141a, { 9, 26, 1, 0 }, 9, 0, 0 },
1063     { 0x02, 0x0181a, { 9, 26, 1, 0 }, 9, 0, 0 },
1064     { 0x02, 0x1040e, { 9, 14, 1, 0 }, 9, 0, 0 },
1065     { 0x03, 0x00425, { 9, 37, 1, 0 }, 9, 0, 0 },
1066     { 0x03, 0x00426, { 9, 38, 1, 0 }, 9, 0, 0 },
1067     { 0x03, 0x00427, { 9, 39, 1, 0 }, 9, 0, 0 },
1068     { 0x04, 0x00408, { 9, 8, 1, 0 }, 9, 0, 0 },
1069     { 0x05, 0x00402, { 9, 2, 1, 0 }, 9, 0, 0 },
1070     { 0x05, 0x00419, { 9, 25, 1, 0 }, 9, 0, 0 },
1071     { 0x05, 0x00422, { 9, 34, 1, 0 }, 9, 0, 0 },
1072     { 0x05, 0x00423, { 9, 35, 1, 0 }, 9, 0, 0 },
1073     { 0x05, 0x0042f, { 9, 47, 1, 0 }, 9, 0, 0 },
1074     { 0x05, 0x0043f, { 9, 63, 1, 0 }, 9, 0, 0 },
1075     { 0x05, 0x00440, { 9, 64, 1, 0 }, 9, 0, 0 },
1076     { 0x05, 0x00444, { 9, 68, 1, 0 }, 9, 0, 0 },
1077     { 0x05, 0x00450, { 9, 80, 1, 0 }, 9, 0, 0 },
1078     { 0x05, 0x0082c, { 9, 44, 1, 0 }, 9, 0, 0 },
1079     { 0x05, 0x00843, { 9, 67, 1, 0 }, 9, 0, 0 },
1080     { 0x05, 0x00c1a, { 9, 26, 1, 0 }, 9, 0, 0 },
1081     { 0x05, 0x01c1a, { 9, 26, 1, 0 }, 9, 0, 0 },
1082     { 0x06, 0x0041f, { 9, 31, 1, 0 }, 9, 0, 0 },
1083     { 0x06, 0x0042c, { 9, 44, 1, 0 }, 9, 0, 0 },
1084     { 0x06, 0x00443, { 9, 67, 1, 0 }, 9, 0, 0 },
1085     { 0x07, 0x00411, { 9, 17, 1, 0 }, 9, 0, 0 },
1086     { 0x08, 0x00412, { 9, 18, 1, 0 }, 9, 0, 0 },
1087     { 0x09, 0x00404, { 9, 4, 1, 0 }, 9, 0, 0 },
1088     { 0x09, 0x00c04, { 9, 4, 1, 0 }, 9, 0, 0 },
1089     { 0x09, 0x01404, { 9, 4, 1, 0 }, 9, 0, 0 },
1090     { 0x09, 0x21404, { 9, 4, 1, 0 }, 9, 0, 0 },
1091     { 0x09, 0x30404, { 9, 4, 1, 0 }, 9, 0, 0 },
1092     { 0x0a, 0x00804, { 9, 4, 1, 0 }, 9, 0, 0 },
1093     { 0x0a, 0x01004, { 9, 4, 1, 0 }, 9, 0, 0 },
1094     { 0x0a, 0x20804, { 9, 4, 1, 0 }, 9, 0, 0 },
1095     { 0x0a, 0x21004, { 9, 4, 1, 0 }, 9, 0, 0 },
1096     { 0x0b, 0x0041e, { 9, 30, 1, 0 }, 9, 0, 0 },
1097     { 0x0c, 0x0040d, { 9, 13, 1, 0 }, 9, 0, 0 },
1098     { 0x0d, 0x00401, { 1, 1, 0, 0 }, 9, 0, 0 },
1099     { 0x0d, 0x00420, { 9, 32, 1, 0 }, 9, 0, 0 },
1100     { 0x0d, 0x00429, { 41, 41, 0, 0 }, 9, 0, 0 },
1101     { 0x0d, 0x0045a, { 9, 90, 1, 0 }, 9, 0, 0 },
1102     { 0x0d, 0x00465, { 9, 101, 1, 0 }, 9, 0, 0 },
1103     { 0x0d, 0x00801, { 1, 1, 0, 0 }, 9, 0, 0 },
1104     { 0x0d, 0x00c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1105     { 0x0d, 0x01001, { 1, 1, 0, 0 }, 9, 0, 0 },
1106     { 0x0d, 0x01401, { 1, 1, 0, 0 }, 9, 0, 0 },
1107     { 0x0d, 0x01801, { 1, 1, 0, 0 }, 9, 0, 0 },
1108     { 0x0d, 0x01c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1109     { 0x0d, 0x02001, { 1, 1, 0, 0 }, 9, 0, 0 },
1110     { 0x0d, 0x02401, { 1, 1, 0, 0 }, 9, 0, 0 },
1111     { 0x0d, 0x02801, { 1, 1, 0, 0 }, 9, 0, 0 },
1112     { 0x0d, 0x02c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1113     { 0x0d, 0x03001, { 1, 1, 0, 0 }, 9, 0, 0 },
1114     { 0x0d, 0x03401, { 1, 1, 0, 0 }, 9, 0, 0 },
1115     { 0x0d, 0x03801, { 1, 1, 0, 0 }, 9, 0, 0 },
1116     { 0x0d, 0x03c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1117     { 0x0d, 0x04001, { 1, 1, 0, 0 }, 9, 0, 0 },
1118     { 0x0e, 0x0042a, { 9, 42, 1, 0 }, 9, 0, 0 },
1119     { 0x0f, 0x00439, { 9, 57, 1, 0 }, 9, 0, 0 },
1120     { 0x0f, 0x00446, { 9, 70, 1, 0 }, 9, 0, 0 },
1121     { 0x0f, 0x00447, { 9, 71, 1, 0 }, 9, 0, 0 },
1122     { 0x0f, 0x00449, { 9, 73, 1, 0 }, 9, 0, 0 },
1123     { 0x0f, 0x0044a, { 9, 74, 1, 0 }, 9, 0, 0 },
1124     { 0x0f, 0x0044b, { 9, 75, 1, 0 }, 9, 0, 0 },
1125     { 0x0f, 0x0044e, { 9, 78, 1, 0 }, 9, 0, 0 },
1126     { 0x0f, 0x0044f, { 9, 79, 1, 0 }, 9, 0, 0 },
1127     { 0x0f, 0x00457, { 9, 87, 1, 0 }, 9, 0, 0 },
1128     { 0x10, 0x00437, { 9, 55, 1, 0 }, 9, 0, 0 },
1129     { 0x10, 0x10437, { 9, 55, 1, 0 }, 9, 0, 0 },
1130     { 0x11, 0x0042b, { 9, 43, 1, 0 }, 9, 0, 0 }
1131 };
1132
1133 static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR lparam)
1134 {
1135     HRESULT hr;
1136     SCRIPT_DIGITSUBSTITUTE sds;
1137     SCRIPT_CONTROL sc;
1138     SCRIPT_STATE ss;
1139     LCID lcid_old;
1140     unsigned int i;
1141
1142     if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
1143
1144     memset(&sds, 0, sizeof(sds));
1145     memset(&sc, 0, sizeof(sc));
1146     memset(&ss, 0, sizeof(ss));
1147
1148     lcid_old = GetThreadLocale();
1149     if (!SetThreadLocale(lcid)) return TRUE;
1150
1151     hr = ScriptRecordDigitSubstitution(lcid, &sds);
1152     ok(hr == S_OK, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr);
1153
1154     hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);
1155     ok(hr == S_OK, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr);
1156
1157     for (i = 0; i < sizeof(subst_data)/sizeof(subst_data[0]); i++)
1158     {
1159         if (group == subst_data[i].group && lcid == subst_data[i].lcid)
1160         {
1161             ok(!memcmp(&sds, &subst_data[i].sds, sizeof(sds)),
1162                "substitution data does not match\n");
1163
1164             ok(sc.uDefaultLanguage == subst_data[i].uDefaultLanguage,
1165                "sc.uDefaultLanguage does not match\n");
1166             ok(sc.fContextDigits == subst_data[i].fContextDigits,
1167                "sc.fContextDigits does not match\n");
1168             ok(ss.fDigitSubstitute == subst_data[i].fDigitSubstitute,
1169                "ss.fDigitSubstitute does not match\n");
1170         }
1171     }
1172     SetThreadLocale(lcid_old);
1173     return TRUE;
1174 }
1175
1176 static void test_digit_substitution(void)
1177 {
1178     BOOL ret;
1179     unsigned int i;
1180     static const LGRPID groups[] =
1181     {
1182         LGRPID_WESTERN_EUROPE,
1183         LGRPID_CENTRAL_EUROPE,
1184         LGRPID_BALTIC,
1185         LGRPID_GREEK,
1186         LGRPID_CYRILLIC,
1187         LGRPID_TURKISH,
1188         LGRPID_JAPANESE,
1189         LGRPID_KOREAN,
1190         LGRPID_TRADITIONAL_CHINESE,
1191         LGRPID_SIMPLIFIED_CHINESE,
1192         LGRPID_THAI,
1193         LGRPID_HEBREW,
1194         LGRPID_ARABIC,
1195         LGRPID_VIETNAMESE,
1196         LGRPID_INDIC,
1197         LGRPID_GEORGIAN,
1198         LGRPID_ARMENIAN
1199     };
1200     HMODULE hKernel32;
1201     static BOOL (WINAPI * pEnumLanguageGroupLocalesA)(LANGGROUPLOCALE_ENUMPROC,LGRPID,DWORD,LONG_PTR);
1202
1203     hKernel32 = GetModuleHandleA("kernel32.dll");
1204     pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
1205
1206     if (!pEnumLanguageGroupLocalesA)
1207     {
1208         trace("EnumLanguageGroupLocalesA not available on this platform\n");
1209         return;
1210     }
1211
1212     for (i = 0; i < sizeof(groups)/sizeof(groups[0]); i++)
1213     {
1214         ret = pEnumLanguageGroupLocalesA(enum_proc, groups[i], 0, 0);
1215         ok(ret, "EnumLanguageGroupLocalesA failed unexpectedly: 0x%08x\n", GetLastError());
1216     }
1217 }
1218
1219 static void test_ScriptGetProperties(void)
1220 {
1221     const SCRIPT_PROPERTIES **props;
1222     HRESULT hr;
1223     int num;
1224
1225     hr = ScriptGetProperties(NULL, NULL);
1226     ok(hr == E_INVALIDARG, "ScriptGetProperties succeeded\n");
1227
1228     hr = ScriptGetProperties(NULL, &num);
1229     ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1230
1231     hr = ScriptGetProperties(&props, NULL);
1232     ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1233
1234     hr = ScriptGetProperties(&props, &num);
1235     ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1236 }
1237
1238 START_TEST(usp10)
1239 {
1240     HWND            hwnd;
1241     HDC             hdc;
1242
1243     unsigned short  pwOutGlyphs[256];
1244
1245     /* We need a valid HDC to drive a lot of Script functions which requires the following    *
1246      * to set up for the tests.                                                               */
1247     hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
1248                            0, 0, 0, NULL);
1249     assert(hwnd != 0);
1250     ShowWindow(hwnd, SW_SHOW);
1251     UpdateWindow(hwnd);
1252
1253     hdc = GetDC(hwnd);                                      /* We now have a hdc             */
1254     ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
1255
1256     test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
1257     test_ScriptGetCMap(hdc, pwOutGlyphs);
1258     test_ScriptCacheGetHeight(hdc);
1259     test_ScriptGetGlyphABCWidth(hdc);
1260
1261     test_ScriptGetFontProperties(hdc);
1262     test_ScriptTextOut(hdc);
1263     test_ScriptXtoX();
1264     test_ScriptString(hdc);
1265     test_ScriptStringXtoCP_CPtoX(hdc);
1266
1267     test_ScriptLayout();
1268     test_digit_substitution();
1269     test_ScriptGetProperties();
1270
1271     ReleaseDC(hwnd, hdc);
1272     DestroyWindow(hwnd);
1273 }