Skip to content

Commit

Permalink
advapi32/tests: Add RegNotifyChangeKeyValue tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Lehman <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>
  • Loading branch information
dlehman-work authored and julliard committed May 7, 2018
1 parent 950b349 commit 8dee2df
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions dlls/advapi32/tests/registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -3484,7 +3484,7 @@ static DWORD WINAPI notify_change_thread(void *arg)
static void test_RegNotifyChangeKeyValue(void)
{
struct notify_data data;
HKEY key, subkey;
HKEY key, subkey, subsubkey;
HANDLE thread;
HANDLE event;
DWORD dwret;
Expand All @@ -3495,7 +3495,7 @@ static void test_RegNotifyChangeKeyValue(void)
ret = RegCreateKeyA(hkey_main, "TestKey", &key);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);

ret = RegNotifyChangeKeyValue(key, TRUE, REG_NOTIFY_CHANGE_NAME, event, TRUE);
ret = RegNotifyChangeKeyValue(key, TRUE, REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_LAST_SET, event, TRUE);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
dwret = WaitForSingleObject(event, 0);
ok(dwret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", dwret);
Expand All @@ -3505,7 +3505,47 @@ static void test_RegNotifyChangeKeyValue(void)
dwret = WaitForSingleObject(event, 0);
ok(dwret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", dwret);

/* watching deeper keys */
ret = RegNotifyChangeKeyValue(key, TRUE, REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_LAST_SET, event, TRUE);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
dwret = WaitForSingleObject(event, 0);
ok(dwret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", dwret);

ret = RegCreateKeyA(subkey, "SubKey", &subsubkey);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
dwret = WaitForSingleObject(event, 0);
ok(dwret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", dwret);

/* watching deeper values */
ret = RegNotifyChangeKeyValue(key, TRUE, REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_LAST_SET, event, TRUE);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
dwret = WaitForSingleObject(event, 0);
ok(dwret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", dwret);

ret = RegSetValueA(subsubkey, NULL, REG_SZ, "SubSubKeyValue", 0);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
dwret = WaitForSingleObject(event, 0);
todo_wine ok(dwret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", dwret);

/* don't watch deeper values */
RegCloseKey(key);
ret = RegOpenKeyA(hkey_main, "TestKey", &key);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);

ret = RegNotifyChangeKeyValue(key, FALSE, REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_LAST_SET, event, TRUE);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
dwret = WaitForSingleObject(event, 0);
ok(dwret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", dwret);

ret = RegSetValueA(subsubkey, NULL, REG_SZ, "SubSubKeyValueNEW", 0);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
dwret = WaitForSingleObject(event, 0);
ok(dwret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", dwret);

RegDeleteKeyA(subkey, "SubKey");
RegDeleteKeyA(key, "SubKey");
RegCloseKey(subsubkey);
RegCloseKey(subkey);
RegCloseKey(key);

/* test same thread with REG_NOTIFY_THREAD_AGNOSTIC */
Expand Down

0 comments on commit 8dee2df

Please sign in to comment.