reg/tests: Add tests for importing Windows 3.1 registry data.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2017-08-07 12:28:35 +00:00 committed by Alexandre Julliard
parent 96fd03b269
commit f95f3fb1bf
1 changed files with 118 additions and 0 deletions

View File

@ -4053,6 +4053,123 @@ static void test_unicode_import_with_whitespace(void)
todo_wine ok(err == ERROR_SUCCESS, "RegDeleteKeyA failed: got %d, expected 0\n", err);
}
static void test_import_31(void)
{
LONG err;
HKEY hkey;
DWORD r;
err = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "RegDeleteKeyA failed: %d\n", err);
/* Check if reg.exe is running with elevated privileges */
err = RegCreateKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_READ|KEY_SET_VALUE, NULL, &hkey, NULL);
if (err == ERROR_ACCESS_DENIED)
{
win_skip("reg.exe is not running with elevated privileges; "
"skipping Windows 3.1 import tests\n");
return;
}
/* Test simple value */
test_import_str("REGEDIT\r\n"
"HKEY_CLASSES_ROOT\\" KEY_BASE " = Value0\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg(hkey, "", REG_SZ, "Value0", 7, 0);
/* Test proper handling of spaces and equals signs */
test_import_str("REGEDIT\r\n"
"HKEY_CLASSES_ROOT\\" KEY_BASE " =Value1\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg(hkey, "", REG_SZ, "Value1", 7, 0);
test_import_str("REGEDIT\r\n"
"HKEY_CLASSES_ROOT\\" KEY_BASE " = Value2\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg(hkey, "", REG_SZ, " Value2", 8, 0);
test_import_str("REGEDIT\r\n"
"HKEY_CLASSES_ROOT\\" KEY_BASE " = Value3 \r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg(hkey, "", REG_SZ, "Value3 ", 8, 0);
test_import_str("REGEDIT\r\n"
"HKEY_CLASSES_ROOT\\" KEY_BASE " Value4\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg(hkey, "", REG_SZ, "Value4", 7, 0);
test_import_str("REGEDIT\r\n"
"HKEY_CLASSES_ROOT\\" KEY_BASE " Value5\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg(hkey, "", REG_SZ, "Value5", 7, 0);
test_import_str("REGEDIT\r\n"
"HKEY_CLASSES_ROOT\\" KEY_BASE "\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg(hkey, "", REG_SZ, "", 1, 0);
test_import_str("REGEDIT\r\n"
"HKEY_CLASSES_ROOT\\" KEY_BASE " \r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg(hkey, "", REG_SZ, "", 1, 0);
test_import_str("REGEDIT\r\n"
"HKEY_CLASSES_ROOT\\" KEY_BASE " = No newline", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg(hkey, "", REG_SZ, "No newline", 11, 0);
err = RegDeleteValueW(hkey, NULL);
todo_wine ok(err == ERROR_SUCCESS, "RegDeleteValue failed: %d\n", err);
/* Test character validity at the start of the line */
test_import_str("REGEDIT\r\n"
" HKEY_CLASSES_ROOT\\" KEY_BASE " = Value1a\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg_nonexist(hkey, "");
test_import_str("REGEDIT\r\n"
" HKEY_CLASSES_ROOT\\" KEY_BASE " = Value1b\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg_nonexist(hkey, "");
test_import_str("REGEDIT\r\n"
"\tHKEY_CLASSES_ROOT\\" KEY_BASE " = Value1c\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg_nonexist(hkey, "");
test_import_str("REGEDIT\r\n"
";HKEY_CLASSES_ROOT\\" KEY_BASE " = Value2a\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg_nonexist(hkey, "");
test_import_str("REGEDIT\r\n"
"#HKEY_CLASSES_ROOT\\" KEY_BASE " = Value2b\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg_nonexist(hkey, "");
/* Test case sensitivity */
test_import_str("REGEDIT\r\n"
"hkey_classes_root\\" KEY_BASE " = Value3a\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg_nonexist(hkey, "");
test_import_str("REGEDIT\r\n"
"hKEY_CLASSES_ROOT\\" KEY_BASE " = Value3b\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg_nonexist(hkey, "");
test_import_str("REGEDIT\r\n"
"Hkey_Classes_Root\\" KEY_BASE " = Value3c\r\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg_nonexist(hkey, "");
RegCloseKey(hkey);
err = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
ok(err == ERROR_SUCCESS, "RegDeleteKeyA failed: %d\n", err);
}
START_TEST(reg)
{
DWORD r;
@ -4069,4 +4186,5 @@ START_TEST(reg)
test_unicode_import();
test_import_with_whitespace();
test_unicode_import_with_whitespace();
test_import_31();
}