twain_32/tests: Link with twain_32.dll. (try 2)

Francois Gouget fgouget at free.fr
Sun Mar 1 16:43:09 CST 2009


---

This time removing the GetProcAddress("DSM_Entry") so we actually take 
advantage of linking with twain_32.dll.
Note that some modifications were needed for us to be able to link with 
twain_32 in crosstest mode (but this has not changed since last time). 
So make_makefiles will need to be re-run.

 dlls/twain_32/Makefile.in       |    1 +
 dlls/twain_32/tests/Makefile.in |    2 +-
 dlls/twain_32/tests/dsm.c       |   65 ++++++++++++++------------------------
 3 files changed, 26 insertions(+), 42 deletions(-)

diff --git a/dlls/twain_32/Makefile.in b/dlls/twain_32/Makefile.in
index 3fc9776..6f9642c 100644
--- a/dlls/twain_32/Makefile.in
+++ b/dlls/twain_32/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = twain_32.dll
+IMPORTLIB = twain_32
 IMPORTS   = kernel32
 
 C_SRCS = \
diff --git a/dlls/twain_32/tests/Makefile.in b/dlls/twain_32/tests/Makefile.in
index 708fb6d..7ed58f8 100644
--- a/dlls/twain_32/tests/Makefile.in
+++ b/dlls/twain_32/tests/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 TESTDLL   = twain_32.dll
-IMPORTS   = user32 gdi32 kernel32
+IMPORTS   = twain_32 user32 gdi32 kernel32
 
 CTESTS = \
 	dsm.c
diff --git a/dlls/twain_32/tests/dsm.c b/dlls/twain_32/tests/dsm.c
index 37ebf3b..4be60e9 100644
--- a/dlls/twain_32/tests/dsm.c
+++ b/dlls/twain_32/tests/dsm.c
@@ -28,7 +28,6 @@
 
 #include "wine/test.h"
 
-static DSMENTRYPROC pDSM_Entry;
 
 static BOOL dsm_RegisterWindowClasses(void)
 {
@@ -53,7 +52,7 @@ static BOOL dsm_RegisterWindowClasses(void)
 static void get_condition_code(TW_IDENTITY *appid, TW_IDENTITY *source, TW_STATUS *status)
 {
     TW_UINT16 rc;
-    rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_STATUS, MSG_GET, status);
+    rc = DSM_Entry(appid, source, DG_CONTROL, DAT_STATUS, MSG_GET, status);
     ok(rc == TWRC_SUCCESS, "Condition code not available, rc %d\n", rc);
 }
 
@@ -177,7 +176,7 @@ static void test_onevalue_cap(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16
     cap.Cap = captype;
     cap.ConType = TWON_DONTCARE16;
 
-    rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_QUERYSUPPORT, &cap);
+    rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_QUERYSUPPORT, &cap);
     get_condition_code(appid, source, &status);
     ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
             "Error [rc %d|cc %d] doing MSG_QUERYSUPPORT for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -195,7 +194,7 @@ static void test_onevalue_cap(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16
         cap.Cap = captype;
         cap.ConType = TWON_DONTCARE16;
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GETCURRENT, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GETCURRENT, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_GETCURRENT for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -213,7 +212,7 @@ static void test_onevalue_cap(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16
         cap.Cap = captype;
         cap.ConType = TWON_DONTCARE16;
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GETDEFAULT, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GETDEFAULT, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_GETDEFAULT for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -232,7 +231,7 @@ static void test_onevalue_cap(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16
         cap.Cap = captype;
         cap.ConType = TWON_DONTCARE16;
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GET, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GET, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_GET for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -248,7 +247,7 @@ static void test_onevalue_cap(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16
         cap.ConType = TWON_ONEVALUE;
         cap.hContainer = alloc_and_set_onevalue(new_value, type);
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_SET, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_SET, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_SET for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -261,7 +260,7 @@ static void test_onevalue_cap(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16
         cap.Cap = captype;
         cap.ConType = TWON_DONTCARE16;
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_RESET, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_RESET, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_RESET for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -286,7 +285,7 @@ static void test_resolution(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16 c
     cap.Cap = captype;
     cap.ConType = TWON_DONTCARE16;
 
-    rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_QUERYSUPPORT, &cap);
+    rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_QUERYSUPPORT, &cap);
     get_condition_code(appid, source, &status);
     ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
             "Error [rc %d|cc %d] doing MSG_QUERYSUPPORT for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -304,7 +303,7 @@ static void test_resolution(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16 c
         cap.Cap = captype;
         cap.ConType = TWON_DONTCARE16;
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GETCURRENT, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GETCURRENT, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_GETCURRENT for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -323,7 +322,7 @@ static void test_resolution(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16 c
         cap.Cap = captype;
         cap.ConType = TWON_DONTCARE16;
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GETDEFAULT, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GETDEFAULT, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_GETDEFAULT for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -341,7 +340,7 @@ static void test_resolution(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16 c
         cap.Cap = captype;
         cap.ConType = TWON_DONTCARE16;
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GET, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GET, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_GET for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -368,7 +367,7 @@ static void test_resolution(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16 c
         cap.ConType = TWON_ONEVALUE;
         cap.hContainer = alloc_and_set_onevalue(new_value, TWTY_FIX32);
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_SET, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_SET, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_SET for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -382,7 +381,7 @@ static void test_resolution(TW_IDENTITY *appid, TW_IDENTITY *source, TW_UINT16 c
         cap.Cap = captype;
         cap.ConType = TWON_DONTCARE16;
 
-        rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_RESET, &cap);
+        rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_RESET, &cap);
         get_condition_code(appid, source, &status);
         ok(rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS,
                 "Error [rc %d|cc %d] doing MSG_RESET for type 0x%x\n", rc, status.ConditionCode, captype);
@@ -403,7 +402,7 @@ static void test_single_source(TW_IDENTITY *appid, TW_IDENTITY *source)
     cap.Cap = CAP_SUPPORTEDCAPS;
     cap.ConType = TWON_DONTCARE16;
 
-    rc = pDSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GET, &cap);
+    rc = DSM_Entry(appid, source, DG_CONTROL, DAT_CAPABILITY, MSG_GET, &cap);
     get_condition_code(appid, source, &status);
     ok(rc == TWRC_SUCCESS || status.ConditionCode == TWCC_SUCCESS,
             "Error obtaining CAP_SUPPORTEDCAPS\n");
@@ -503,7 +502,7 @@ static void test_sources(TW_IDENTITY *appid)
     int scannercount = 0;
 
     memset(&source, 0, sizeof(source));
-    rc = pDSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETFIRST, &source);
+    rc = DSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETFIRST, &source);
     get_condition_code(appid, NULL, &status);
     ok( (rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS) ||
         (rc == TWRC_FAILURE && status.ConditionCode == TWCC_NODS),
@@ -518,13 +517,13 @@ static void test_sources(TW_IDENTITY *appid)
             source.ProtocolMajor, source.ProtocolMinor, source.SupportedGroups,
             source.Manufacturer, source.ProductFamily, source.ProductName);
         memset(&source, 0, sizeof(source));
-        rc = pDSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETNEXT, &source);
+        rc = DSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETNEXT, &source);
         get_condition_code(appid, NULL, &status);
         ok(rc == TWRC_SUCCESS || rc == TWRC_ENDOFLIST, "Get next source failed, rc %d, cc %d\n", rc, status.ConditionCode);
     }
 
     memset(&source, 0, sizeof(source));
-    rc = pDSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETDEFAULT, &source);
+    rc = DSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETDEFAULT, &source);
     get_condition_code(appid, NULL, &status);
     ok( (rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS) ||
         (rc == TWRC_FAILURE && status.ConditionCode == TWCC_NODS),
@@ -532,12 +531,12 @@ static void test_sources(TW_IDENTITY *appid)
 
     if (rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS)
     {
-        rc = pDSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &source);
+        rc = DSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &source);
         get_condition_code(appid, NULL, &status);
 
         if (rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS)
         {
-            rc = pDSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, &source);
+            rc = DSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, &source);
             get_condition_code(appid, NULL, &status);
             ok(rc == TWRC_SUCCESS, "Close DS Failed, rc %d, cc %d\n", rc, status.ConditionCode);
         }
@@ -547,18 +546,18 @@ static void test_sources(TW_IDENTITY *appid)
     {
         trace("Interactive, so trying userselect\n");
         memset(&source, 0, sizeof(source));
-        rc = pDSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_USERSELECT, &source);
+        rc = DSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_USERSELECT, &source);
         get_condition_code(appid, NULL, &status);
         ok(rc == TWRC_SUCCESS || rc == TWRC_CANCEL, "Userselect failed, rc %d, cc %d\n", rc, status.ConditionCode);
 
         if (rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS)
         {
-            rc = pDSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &source);
+            rc = DSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &source);
             get_condition_code(appid, NULL, &status);
             if (rc == TWRC_SUCCESS && status.ConditionCode == TWCC_SUCCESS)
             {
                 test_single_source(appid, &source);
-                rc = pDSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, &source);
+                rc = DSM_Entry(appid, NULL, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, &source);
                 get_condition_code(appid, NULL, &status);
                 ok(rc == TWRC_SUCCESS, "Close DS Failed, rc %d, cc %d\n", rc, status.ConditionCode);
             }
@@ -572,24 +571,9 @@ START_TEST(dsm)
     TW_IDENTITY appid;
     TW_UINT16 rc;
     HANDLE hwnd;
-    HMODULE htwain;
 
     if (!dsm_RegisterWindowClasses()) assert(0);
 
-    htwain = LoadLibraryA("twain_32.dll");
-    if (! htwain)
-    {
-        win_skip("twain_32.dll not available, skipping tests\n");
-        return;
-    }
-    pDSM_Entry = (void*)GetProcAddress(htwain, "DSM_Entry");
-    ok(pDSM_Entry != NULL, "Unable to GetProcAddress DSM_Entry\n");
-    if (! pDSM_Entry)
-    {
-        win_skip("DSM_Entry not available, skipping tests\n");
-        return;
-    }
-
     memset(&appid, 0, sizeof(appid));
     appid.Version.Language = TWLG_ENGLISH_USA;
     appid.Version.Country = TWCY_USA;
@@ -601,14 +585,13 @@ START_TEST(dsm)
                         CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                         NULL, NULL, GetModuleHandleA(0), NULL);
 
-    rc = pDSM_Entry(&appid, NULL, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, (TW_MEMREF) &hwnd);
+    rc = DSM_Entry(&appid, NULL, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, (TW_MEMREF) &hwnd);
     ok(rc == TWRC_SUCCESS, "MSG_OPENDSM returned %d\n", rc);
 
     test_sources(&appid);
 
-    rc = pDSM_Entry(&appid, NULL, DG_CONTROL, DAT_PARENT, MSG_CLOSEDSM, (TW_MEMREF) &hwnd);
+    rc = DSM_Entry(&appid, NULL, DG_CONTROL, DAT_PARENT, MSG_CLOSEDSM, (TW_MEMREF) &hwnd);
     ok(rc == TWRC_SUCCESS, "MSG_CLOSEDSM returned %d\n", rc);
 
     DestroyWindow(hwnd);
-    FreeLibrary(htwain);
 }
-- 
1.5.6.5




More information about the wine-patches mailing list