Hans Leidekker : usp10: Fix all failing tests on Windows and Wine.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Dec 26 06:49:31 CST 2006


Module: wine
Branch: master
Commit: 55f385c8d7955cbd504b203afbf41b0c3cc45dfb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=55f385c8d7955cbd504b203afbf41b0c3cc45dfb

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Sun Dec 24 12:39:27 2006 +0100

usp10: Fix all failing tests on Windows and Wine.

---

 dlls/usp10/tests/usp10.c |   62 +++++++--------------------------------------
 dlls/usp10/usp10.c       |   11 +++----
 2 files changed, 15 insertions(+), 58 deletions(-)

diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index ae28be8..7a949dc 100644
--- a/dlls/usp10/tests/usp10.c
+++ b/dlls/usp10/tests/usp10.c
@@ -313,21 +313,12 @@ static void test_ScriptGetCMap(HDC hdc,
 
 }
 
-static void test_ScriptGetFontProperties(void)
+static void test_ScriptGetFontProperties(HDC hdc)
 {
     HRESULT         hr;
-    HDC             hdc;
-    HWND            hwnd;
     SCRIPT_CACHE    psc,old_psc;
     SCRIPT_FONTPROPERTIES sfp;
 
-    /* Only do the bare minumum to get a valid hdc */
-    hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,0, 0, 0, NULL);
-    assert(hwnd != 0);
-
-    hdc = GetDC(hwnd);
-    ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
-
     /* Some sanity checks for ScriptGetFontProperties */
 
     hr = ScriptGetFontProperties(NULL,NULL,NULL);
@@ -383,17 +374,11 @@ static void test_ScriptGetFontProperties
     ok( psc == old_psc, "Expected psc not to be changed, was %p is now %p\n", old_psc, psc);
     ScriptFreeCache(&psc);
     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
-
-    /* Cleanup */
-    ReleaseDC(hwnd, hdc);
-    DestroyWindow(hwnd);
 }
 
-static void test_ScriptTextOut(void)
+static void test_ScriptTextOut(HDC hdc)
 {
     HRESULT         hr;
-    HWND            hwnd;
-    HDC             hdc;
 
     int             cInChars;
     int             cMaxItems;
@@ -418,17 +403,6 @@ static void test_ScriptTextOut(void)
     SCRIPT_LOGATTR  *psla;
     SCRIPT_LOGATTR  sla[256];
 
-    /* We need a valid HDC to drive a lot of Script functions which requires the following    *
-     * to set up for the tests.                                                               */
-    hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
-                           0, 0, 0, NULL);
-    assert(hwnd != 0);
-    ShowWindow(hwnd, SW_SHOW);
-    UpdateWindow(hwnd);
-
-    hdc = GetDC(hwnd);                                      /* We now have a hdc             */
-    ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
-
     /* This is a valid test that will cause parsing to take place                             */
     cInChars = 5;
     cMaxItems = 255;
@@ -519,8 +493,6 @@ static void test_ScriptTextOut(void)
             ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
         }
     }
-    ReleaseDC(hwnd, hdc);
-    DestroyWindow(hwnd);
 }
 
 static void test_ScriptXtoX(void)
@@ -632,20 +604,18 @@ static void test_ScriptXtoX(void)
 
 }
 
-static void test_ScriptString(void)
+static void test_ScriptString(HDC hdc)
 {
 /*******************************************************************************************
  *
  * This set of tests are for the string functions of uniscribe.  The ScriptStringAnalyse
- * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer.  This 
- * memory if freed by ScriptStringFree.  There needs to be a valid hdc for this this as 
- * ScriptStrinAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
+ * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer.  This
+ * memory if freed by ScriptStringFree.  There needs to be a valid hdc for this as
+ * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
  *
  */
 
     HRESULT         hr;
-    HWND            hwnd;
-    HDC             hdc = 0;
     WCHAR           teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
     int             String = (sizeof(teststr)/sizeof(WCHAR))-1;
     int             Glyphs = String * 2 + 16;
@@ -668,16 +638,6 @@ static void test_ScriptString(void)
     BOOL            Disabled = FALSE;
 
     LOGFONTA        lf;
-    HFONT           zfont;
-
-    /* We need a valid HDC to drive a lot of Script functions which requires the following    *
-     * to set up for the tests.                                                               */
-    hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
-                           0, 0, 0, NULL);
-    assert(hwnd != 0);
-
-    hdc = GetDC(hwnd);                                      /* We now have a hdc             */
-    ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
 
     lstrcpyA(lf.lfFaceName, "Symbol");
     lf.lfHeight = 10;
@@ -689,10 +649,8 @@ static void test_ScriptString(void)
     lf.lfWeight = 300;
     lf.lfWidth = 10;
 
-    zfont = (HFONT) SelectObject(hdc, CreateFontIndirectA(&lf));
- 
     Charset = -1;     /* this flag indicates unicode input */
-    /* Test without hdc to get E_INVALIDARG */
+    /* Test without hdc to get E_PENDING */
     hr = ScriptStringAnalyse( NULL, teststr, String, Glyphs, Charset, Flags,
                              ReqWidth, &Control, &State, Dx, &Tabdef,
                              &InClass, &ssa);
@@ -1298,10 +1256,10 @@ START_TEST(usp10)
     test_ScriptCacheGetHeight(hdc);
     test_ScriptGetGlyphABCWidth(hdc);
 
-    test_ScriptGetFontProperties();
-    test_ScriptTextOut();
+    test_ScriptGetFontProperties(hdc);
+    test_ScriptTextOut(hdc);
     test_ScriptXtoX();
-    test_ScriptString();
+    test_ScriptString(hdc);
     test_ScriptStringXtoCP_CPtoX(hdc);
 
     test_ScriptLayout();
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index a630622..360d24e 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -511,12 +511,11 @@ HRESULT WINAPI ScriptStringAnalyse(HDC h
       hdc, pString, cString, cGlyphs, iCharset, dwFlags,
       iReqWidth, psControl, psState, piDx, pTabdef, pbInClass, pssa);
 
-  if (1 > cString || NULL == pString) {
-    return E_INVALIDARG;
-  }
-  if ((dwFlags & SSA_GLYPHS) && NULL == hdc) {
-    return E_PENDING;
-  }
+    if (cString < 1 || !pString)
+        return E_INVALIDARG;
+
+    if ((dwFlags & SSA_GLYPHS) && !hdc)
+        return E_PENDING;
 
     analysis = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
                        sizeof(StringAnalysis));




More information about the wine-cvs mailing list