shell32/tests: Fix out of memory errors and their underlying cause.

The out of memory errors were happening because getstring_test was using
len unitialized when GetString failed. The underlying cause was that
deleting the keys would fail because RegDeleteKey does not work if the
key has subkeys, and one of the keys has a subkey. The test fails when
the keys are still there. The subkey is now deleted before the key that
contains it.

Signed-off-by: Theodore Dubois <tblodt@icloud.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Theodore Dubois 2016-06-05 09:35:38 -07:00 committed by Alexandre Julliard
parent 2afd2f705f
commit fbbac88519
1 changed files with 13 additions and 13 deletions

View File

@ -113,21 +113,20 @@ static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCW
ok_(__FILE__, line)(hr == S_OK, "IQueryAssociations::Init failed, 0x%x\n", hr);
hr = IQueryAssociations_GetString(assoc, ASSOCF_NONE, str, NULL, NULL, &len);
if (hr != S_FALSE) {
if (expected_string) {
ok_(__FILE__, line)(SUCCEEDED(hr), "GetString returned 0x%x, expected success\n", hr);
} else {
ok_(__FILE__, line)(FAILED(hr), "GetString returned 0x%x, expected failure\n", hr);
}
}
buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
ok_(__FILE__, line)(buffer != NULL, "out of memory\n");
hr = IQueryAssociations_GetString(assoc, ASSOCF_NONE, str, NULL, buffer, &len);
if (expected_string) {
ok_(__FILE__, line)(hr == S_FALSE, "GetString returned 0x%x, expected S_FALSE\n", hr);
if (hr != S_FALSE)
return; /* don't try to allocate memory */
buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
ok_(__FILE__, line)(buffer != NULL, "out of memory\n");
hr = IQueryAssociations_GetString(assoc, 0, str, NULL, buffer, &len);
ok_(__FILE__, line)(hr == S_OK, "GetString returned 0x%x, expected S_OK\n", hr);
ok_(__FILE__, line)(lstrcmpW(buffer, expected_string) == 0, "GetString returned %s, expected %s\n",
wine_dbgstr_w(buffer), wine_dbgstr_w(expected_string));
} else {
ok_(__FILE__, line)(FAILED(hr), "GetString returned 0x%x, expected failure\n", hr);
}
}
@ -176,8 +175,9 @@ static void test_IQueryAssociations_GetString(void)
getstring_test(test_progidW, NULL, ASSOCSTR_DEFAULTICON, test_iconW, __LINE__);
getstring_test(NULL, test_progid_key, ASSOCSTR_DEFAULTICON, test_iconW, __LINE__);
RegDeleteKeyW(HKEY_CLASSES_ROOT, test_extensionW);
RegDeleteKeyW(test_progid_key, DefaultIconW);
RegDeleteKeyW(HKEY_CLASSES_ROOT, test_progidW);
RegDeleteKeyW(HKEY_CLASSES_ROOT, test_extensionW);
hr = CoCreateInstance(&CLSID_QueryAssociations, NULL, CLSCTX_INPROC_SERVER, &IID_IQueryAssociations, (void*)&assoc);
ok(hr == S_OK, "failed to create object, 0x%x\n", hr);