Commit 247e611d authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

regedit/tests: Add tests for key creation and key deletion.

parent 80d248c5
......@@ -163,6 +163,33 @@ static void r_verify_reg_nonexist(unsigned line, HKEY key, const char *value_nam
value_name);
}
#define verify_key_exist(k,s) verify_key_exist_(__LINE__,k,s)
static void verify_key_exist_(unsigned line, HKEY key_base, const char *subkey)
{
HKEY hkey;
LONG lr;
lr = RegOpenKeyExA(key_base, subkey, 0, KEY_READ, &hkey);
lok(lr == ERROR_SUCCESS, "RegOpenKeyExA failed: got %d\n", lr);
if (hkey)
RegCloseKey(hkey);
}
#define verify_key_nonexist(k,s) verify_key_nonexist_(__LINE__,k,s)
static void verify_key_nonexist_(unsigned line, HKEY key_base, const char *subkey)
{
HKEY hkey;
LONG lr;
lr = RegOpenKeyExA(key_base, subkey, 0, KEY_READ, &hkey);
lok(lr == ERROR_FILE_NOT_FOUND, "registry key '%s' shouldn't exist; got %d, expected 2\n",
subkey, lr);
if (hkey)
RegCloseKey(hkey);
}
#define KEY_BASE "Software\\Wine\\regedit_test"
static void test_basic_import(void)
......@@ -1110,6 +1137,82 @@ static void test_import_with_whitespace(void)
ok(lr == ERROR_SUCCESS, "RegDeleteKeyA failed: got %d, expected 0\n", lr);
}
static void test_key_creation_and_deletion(void)
{
HKEY hkey;
LONG lr;
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n\n");
lr = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
ok(lr == ERROR_SUCCESS, "RegOpenKeyExA failed: got %d, expected 0\n", lr);
/* Test key creation */
exec_import_str("REGEDIT4\n\n"
"HKEY_CURRENT_USER\\" KEY_BASE "\\No_Opening_Bracket]\n");
verify_key_nonexist(hkey, "No_Opening_Bracket");
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\No_Closing_Bracket\n");
todo_wine verify_key_nonexist(hkey, "No_Closing_Bracket");
exec_import_str("REGEDIT4\n\n"
"[ HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1a]\n");
verify_key_nonexist(hkey, "Subkey1a");
exec_import_str("REGEDIT4\n\n"
"[\tHKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1b]\n");
verify_key_nonexist(hkey, "Subkey1b");
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1c ]\n");
verify_key_exist(hkey, "Subkey1c ");
lr = RegDeleteKeyA(hkey, "Subkey1c ");
ok(lr == ERROR_SUCCESS, "got %d, expected 0\n", lr);
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1d\t]\n");
verify_key_exist(hkey, "Subkey1d\t");
lr = RegDeleteKeyA(hkey, "Subkey1d\t");
ok(lr == ERROR_SUCCESS, "got %d, expected 0\n", lr);
/* Test key deletion. We start by creating some registry keys. */
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2a]\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2b]\n\n");
verify_key_exist(hkey, "Subkey2a");
verify_key_exist(hkey, "Subkey2b");
exec_import_str("REGEDIT4\n\n"
"[ -HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2a]\n");
verify_key_exist(hkey, "Subkey2a");
exec_import_str("REGEDIT4\n\n"
"[\t-HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2b]\n");
verify_key_exist(hkey, "Subkey2b");
exec_import_str("REGEDIT4\n\n"
"[- HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2a]\n");
verify_key_exist(hkey, "Subkey2a");
exec_import_str("REGEDIT4\n\n"
"[-\tHKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2b\t]\n");
verify_key_exist(hkey, "Subkey2b");
exec_import_str("REGEDIT4\n\n"
"[-HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2a]\n\n"
"[-HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2b]\n\n");
verify_key_nonexist(hkey, "Subkey2a");
verify_key_nonexist(hkey, "Subkey2b");
lr = RegCloseKey(hkey);
ok(lr == ERROR_SUCCESS, "RegCloseKey failed: got %d, expected 0\n", lr);
lr = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
todo_wine ok(lr == ERROR_SUCCESS, "RegDeleteKeyA failed: got %d, expected 0\n", lr);
}
START_TEST(regedit)
{
WCHAR wchar_test[] = {0xFEFF,'W','i','n','d','o','w','s',' ','R','e','g',
......@@ -1129,4 +1232,5 @@ START_TEST(regedit)
test_invalid_import_31();
test_comments();
test_import_with_whitespace();
test_key_creation_and_deletion();
}
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