[PATCH v2] msado15: Implement _Command get/put CommandType

Aaro Altonen a.altonen at hotmail.com
Mon May 25 09:01:30 CDT 2020


Signed-off-by: Aaro Altonen <a.altonen at hotmail.com>
---
v2:
- fix variable type
- set default value before _Command_get_CommandType() in tests
(thanks Hans)
---
 dlls/msado15/command.c       | 34 ++++++++++++++++++++++++++++------
 dlls/msado15/tests/msado15.c | 13 +++++++++++++
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/dlls/msado15/command.c b/dlls/msado15/command.c
index a96fd73990..9081f1554f 100644
--- a/dlls/msado15/command.c
+++ b/dlls/msado15/command.c
@@ -31,8 +31,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(msado15);
 
 struct command
 {
-    _Command Command_iface;
-    LONG     ref;
+    _Command        Command_iface;
+    LONG            ref;
+    CommandTypeEnum type;
 };
 
 static inline struct command *impl_from_Command( _Command *iface )
@@ -193,14 +194,34 @@ static HRESULT WINAPI command_get_Parameters( _Command *iface, Parameters **para
 
 static HRESULT WINAPI command_put_CommandType( _Command *iface, CommandTypeEnum type )
 {
-    FIXME( "%p, %d\n", iface, type );
-    return E_NOTIMPL;
+    struct command *command = impl_from_Command( iface );
+
+    TRACE( "%p, %d\n", iface, type );
+
+    switch (type)
+    {
+    case adCmdUnspecified:
+    case adCmdUnknown:
+    case adCmdText:
+    case adCmdTable:
+    case adCmdStoredProc:
+    case adCmdFile:
+    case adCmdTableDirect:
+        command->type = type;
+        return S_OK;
+    }
+
+    return MAKE_ADO_HRESULT( adErrInvalidArgument );
 }
 
 static HRESULT WINAPI command_get_CommandType( _Command *iface, CommandTypeEnum *type )
 {
-    FIXME( "%p, %p\n", iface, type );
-    return E_NOTIMPL;
+    struct command *command = impl_from_Command( iface );
+
+    TRACE( "%p, %p\n", iface, type );
+
+    *type = command->type;
+    return S_OK;
 }
 
 static HRESULT WINAPI command_get_Name(_Command *iface, BSTR *name)
@@ -305,6 +326,7 @@ HRESULT Command_create( void **obj )
 
     if (!(command = heap_alloc( sizeof(*command) ))) return E_OUTOFMEMORY;
     command->Command_iface.lpVtbl = &command_vtbl;
+    command->type = adCmdUnknown;
     command->ref = 1;
 
     *obj = &command->Command_iface;
diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c
index fb77936bba..b17430a93d 100644
--- a/dlls/msado15/tests/msado15.c
+++ b/dlls/msado15/tests/msado15.c
@@ -742,6 +742,7 @@ static void test_Command(void)
     _ADO *ado;
     Command15 *command15;
     Command25 *command25;
+    CommandTypeEnum cmd_type = adCmdUnspecified;
 
     hr = CoCreateInstance( &CLSID_Command, NULL, CLSCTX_INPROC_SERVER, &IID__Command, (void **)&command );
     ok( hr == S_OK, "got %08x\n", hr );
@@ -758,6 +759,18 @@ static void test_Command(void)
     ok( hr == S_OK, "got %08x\n", hr );
     Command25_Release( command25 );
 
+    hr = _Command_get_CommandType( command, &cmd_type );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( cmd_type == adCmdUnknown, "got %08x\n", cmd_type );
+
+    _Command_put_CommandType( command, adCmdText );
+    hr = _Command_get_CommandType( command, &cmd_type );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( cmd_type == adCmdText, "got %08x\n", cmd_type );
+
+    hr = _Command_put_CommandType( command, 0xdeadbeef );
+    ok( hr == MAKE_ADO_HRESULT( adErrInvalidArgument ), "got %08x\n", hr );
+
     _Command_Release( command );
 }
 
-- 
2.26.2




More information about the wine-devel mailing list