Commit 440d3717 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

advapi32/tests: Add some tests for RegRenameKey().

parent 4bd160da
......@@ -4475,6 +4475,78 @@ static void test_EnumDynamicTimeZoneInformation(void)
RegCloseKey(key);
}
static void test_RegRenameKey(void)
{
HKEY key, key2;
LSTATUS ret;
ret = RegRenameKey(NULL, NULL, NULL);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(NULL, NULL, L"newname");
todo_wine
ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(NULL, L"oldname", NULL);
todo_wine
ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(NULL, L"oldname", L"newname");
todo_wine
ok(ret == ERROR_INVALID_HANDLE, "Unexpected return value %ld.\n", ret);
ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_READ, NULL, &key, NULL);
ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, NULL, L"TestNewRenameKey");
todo_wine
ok(ret == ERROR_ACCESS_DENIED, "Unexpected return value %ld.\n", ret);
RegCloseKey(key);
/* Rename itself. */
ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL);
ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, NULL, NULL);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, NULL, L"TestNewRenameKey");
todo_wine
ok(!ret, "Unexpected return value %ld.\n", ret);
RegCloseKey(key);
ret = RegDeleteKeyA(hkey_main, "TestNewRenameKey");
todo_wine
ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegDeleteKeyA(hkey_main, "TestRenameKey");
todo_wine
ok(ret, "Unexpected return value %ld.\n", ret);
/* Subkey does not exist. */
ret = RegCreateKeyExA(hkey_main, "TestRenameKey", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL);
ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, L"unknown_subkey", NULL);
todo_wine
ok(ret == ERROR_FILE_NOT_FOUND, "Unexpected return value %ld.\n", ret);
ret = RegRenameKey(key, L"unknown_subkey", L"known_subkey");
todo_wine
ok(ret == ERROR_FILE_NOT_FOUND, "Unexpected return value %ld.\n", ret);
/* Rename existing subkey. */
ret = RegCreateKeyExA(key, "known_subkey", 0, NULL, 0, KEY_WRITE, NULL, &key2, NULL);
ok(!ret, "Unexpected return value %ld.\n", ret);
RegCloseKey(key2);
ret = RegRenameKey(key, L"known_subkey", L"renamed_subkey");
todo_wine
ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegDeleteKeyA(key, "renamed_subkey");
todo_wine
ok(!ret, "Unexpected return value %ld.\n", ret);
ret = RegDeleteKeyA(key, "known_subkey");
todo_wine
ok(ret, "Unexpected return value %ld.\n", ret);
RegCloseKey(key);
}
START_TEST(registry)
{
/* Load pointers for functions that are not available in all Windows versions */
......@@ -4514,6 +4586,7 @@ START_TEST(registry)
test_RegLoadMUIString();
test_EnumDynamicTimeZoneInformation();
test_perflib_key();
test_RegRenameKey();
/* cleanup */
delete_key( hkey_main );
......
......@@ -178,6 +178,7 @@ WINADVAPI LSTATUS WINAPI RegQueryValueW(HKEY,LPCWSTR,LPWSTR,LPLONG);
WINADVAPI LSTATUS WINAPI RegQueryValueExA(HKEY,LPCSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
WINADVAPI LSTATUS WINAPI RegQueryValueExW(HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
#define RegQueryValueEx WINELIB_NAME_AW(RegQueryValueEx)
WINADVAPI LSTATUS WINAPI RegRenameKey(HKEY,LPCWSTR,LPCWSTR);
WINADVAPI LSTATUS WINAPI RegReplaceKeyA(HKEY,LPCSTR,LPCSTR,LPCSTR);
WINADVAPI LSTATUS WINAPI RegReplaceKeyW(HKEY,LPCWSTR,LPCWSTR,LPCWSTR);
#define RegReplaceKey WINELIB_NAME_AW(RegReplaceKey)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment