From: Vibhav Pant vibhavp@gmail.com
--- dlls/cfgmgr32/tests/cfgmgr32.c | 38 ++++++++++++++++++++++++++++++++++ include/cfgmgr32.h | 1 + 2 files changed, 39 insertions(+)
diff --git a/dlls/cfgmgr32/tests/cfgmgr32.c b/dlls/cfgmgr32/tests/cfgmgr32.c index 1e949093689..2854876d09d 100644 --- a/dlls/cfgmgr32/tests/cfgmgr32.c +++ b/dlls/cfgmgr32/tests/cfgmgr32.c @@ -282,8 +282,46 @@ static void test_CM_Get_Device_ID_List(void) free(buf); }
+DWORD WINAPI notify_callback( HCMNOTIFICATION notify, void *ctx, CM_NOTIFY_ACTION actoin, + CM_NOTIFY_EVENT_DATA *data, DWORD size ) +{ + return ERROR_SUCCESS; +} + +static void test_CM_Register_Notification( void ) +{ + CM_NOTIFY_FILTER filter = {0}; + HCMNOTIFICATION notify; + CONFIGRET ret; + + filter.cbSize = sizeof( CM_NOTIFY_FILTER ); + filter.Flags = CM_NOTIFY_FILTER_FLAG_ALL_INTERFACE_CLASSES; + filter.FilterType = CM_NOTIFY_FILTER_TYPE_DEVICEINTERFACE; + + ret = CM_Register_Notification( NULL, NULL, NULL, NULL ); + todo_wine ok( ret == CR_FAILURE, "Expected 0x13, got %#lx.\n", ret ); + + ret = CM_Register_Notification( NULL, NULL, NULL, ¬ify ); + todo_wine ok( ret == CR_INVALID_DATA, "Expected 0x1f, got %#lx.\n", ret ); + + ret = CM_Register_Notification( &filter, NULL, NULL, ¬ify ); + todo_wine ok( ret == CR_INVALID_DATA, "Expected 0x1f, got %#lx.\n", ret ); + + filter.cbSize +=1; + ret = CM_Register_Notification( &filter, NULL, notify_callback, ¬ify ); + todo_wine ok( ret == CR_INVALID_DATA, "Expected 0x1f, got %#lx.\n", ret ); + + filter.cbSize -=1; + ret = CM_Register_Notification( &filter, NULL, notify_callback, ¬ify ); + todo_wine ok( !ret, "Expected 0, got %#lx.\n", ret ); + + ret = CM_Unregister_Notification( notify ); + todo_wine ok( !ret, "Expected 0, got %#lx.\n", ret ); +} + START_TEST(cfgmgr32) { test_CM_MapCrToWin32Err(); test_CM_Get_Device_ID_List(); + test_CM_Register_Notification(); } diff --git a/include/cfgmgr32.h b/include/cfgmgr32.h index 269aec9873c..3e814757e2b 100644 --- a/include/cfgmgr32.h +++ b/include/cfgmgr32.h @@ -204,6 +204,7 @@ typedef CHAR *DEVNODEID_A, *DEVINSTID_A; typedef WCHAR *DEVNODEID_W, *DEVINSTID_W; typedef ULONG REGDISPOSITION;
+#define CM_NOTIFY_FILTER_FLAG_ALL_INTERFACE_CLASSES 0x0001 typedef enum _CM_NOTIFY_FILTER_TYPE { CM_NOTIFY_FILTER_TYPE_DEVICEINTERFACE,