[PATCH v2] user32/tests: Fix the clipboard format id vs. atom table checks.
Francois Gouget
fgouget at codeweavers.com
Thu May 20 17:10:22 CDT 2021
One cannot assume that a random integer has zero chance of being a valid
atom.
Reenable the GlobalFindAtomA() check in a todo_wine.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
v2: No need for todo_wine for the global atom length check.
dlls/user32/tests/clipboard.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c
index 2fceab6c0f6..d75e8fc3c32 100644
--- a/dlls/user32/tests/clipboard.c
+++ b/dlls/user32/tests/clipboard.c
@@ -391,29 +391,30 @@ static void test_RegisterClipboardFormatA(void)
lstrcpyA(buf, "foo");
SetLastError(0xdeadbeef);
len = GetAtomNameA((ATOM)format_id, buf, ARRAY_SIZE(buf));
- ok(len == 0, "GetAtomNameA should fail\n");
- ok(GetLastError() == ERROR_INVALID_HANDLE, "err %d\n", GetLastError());
+ ok(len == 0 || lstrcmpA(buf, "my_cool_clipboard_format") != 0,
+ "format_id should not be a valid local atom\n");
+ ok(len != 0 || GetLastError() == ERROR_INVALID_HANDLE,
+ "err %d\n", GetLastError());
-todo_wine
-{
lstrcpyA(buf, "foo");
SetLastError(0xdeadbeef);
len = GlobalGetAtomNameA((ATOM)format_id, buf, ARRAY_SIZE(buf));
- ok(len == 0, "GlobalGetAtomNameA should fail\n");
- ok(GetLastError() == ERROR_INVALID_HANDLE, "err %d\n", GetLastError());
-}
+ todo_wine ok(len == 0 || lstrcmpA(buf, "my_cool_clipboard_format") != 0,
+ "format_id should not be a valid global atom\n");
+ ok(len != 0 || GetLastError() == ERROR_INVALID_HANDLE,
+ "err %d\n", GetLastError());
SetLastError(0xdeadbeef);
atom_id = FindAtomA("my_cool_clipboard_format");
- ok(atom_id == 0, "FindAtomA should fail\n");
+ ok(atom_id == 0, "FindAtomA should fail, but it returned %x (format_id=%x)\n", atom_id, format_id);
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "err %d\n", GetLastError());
- if (0)
+ todo_wine
{
/* this relies on the clipboard and global atom table being different */
SetLastError(0xdeadbeef);
atom_id = GlobalFindAtomA("my_cool_clipboard_format");
- ok(atom_id == 0, "GlobalFindAtomA should fail\n");
+ ok(atom_id == 0, "GlobalFindAtomA should fail, but it returned %x (format_id=%x)\n", atom_id, format_id);
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "err %d\n", GetLastError());
}
--
2.20.1
More information about the wine-devel
mailing list