user32/tests: Retry when opening the clipboard.
As the clipboard is a shared resource, we cannot expect that no other app hasn't openeded it. So wrap clipboard access with a retry feature in case of failure. Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
This commit is contained in:
parent
29ebb5b3ec
commit
e439611d10
1 changed files with 32 additions and 3 deletions
|
@ -32,6 +32,35 @@
|
|||
#define ID_EDITTEST2 99
|
||||
#define MAXLEN 200
|
||||
|
||||
static BOOL open_clipboard(HWND hwnd)
|
||||
{
|
||||
DWORD start = GetTickCount();
|
||||
while (1)
|
||||
{
|
||||
BOOL ret = OpenClipboard(hwnd);
|
||||
if (ret || GetLastError() != ERROR_ACCESS_DENIED)
|
||||
return ret;
|
||||
if (GetTickCount() - start > 100)
|
||||
{
|
||||
char classname[256];
|
||||
DWORD le = GetLastError();
|
||||
HWND clipwnd = GetOpenClipboardWindow();
|
||||
/* Provide a hint as to the source of interference:
|
||||
* - The class name would typically be CLIPBRDWNDCLASS if the
|
||||
* clipboard was opened by a Windows application using the
|
||||
* ole32 API.
|
||||
* - And it would be __wine_clipboard_manager if it was opened in
|
||||
* response to a native application.
|
||||
*/
|
||||
GetClassNameA(clipwnd, classname, ARRAY_SIZE(classname));
|
||||
trace("%p (%s) opened the clipboard\n", clipwnd, classname);
|
||||
SetLastError(le);
|
||||
return ret;
|
||||
}
|
||||
Sleep(15);
|
||||
}
|
||||
}
|
||||
|
||||
struct edit_notify {
|
||||
int en_change, en_maxtext, en_update;
|
||||
};
|
||||
|
@ -2192,7 +2221,7 @@ static void test_espassword(void)
|
|||
ok(r == strlen(password), "Expected: %s, got len %ld\n", password, r);
|
||||
ok(strcmp(buffer, password) == 0, "expected %s, got %s\n", password, buffer);
|
||||
|
||||
r = OpenClipboard(hwEdit);
|
||||
r = open_clipboard(hwEdit);
|
||||
ok(r == TRUE, "expected %d, got %ld le=%lu\n", TRUE, r, GetLastError());
|
||||
r = EmptyClipboard();
|
||||
ok(r == TRUE, "expected %d, got %ld\n", TRUE, r);
|
||||
|
@ -3195,7 +3224,7 @@ static void test_paste(void)
|
|||
strcpy(buffer, str);
|
||||
GlobalUnlock(hmem);
|
||||
|
||||
r = OpenClipboard(hEdit);
|
||||
r = open_clipboard(hEdit);
|
||||
ok(r == TRUE, "expected %d, got %d le=%lu\n", TRUE, r, GetLastError());
|
||||
r = EmptyClipboard();
|
||||
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
||||
|
@ -3218,7 +3247,7 @@ static void test_paste(void)
|
|||
strcpy(buffer, str2);
|
||||
GlobalUnlock(hmem);
|
||||
|
||||
r = OpenClipboard(hEdit);
|
||||
r = open_clipboard(hEdit);
|
||||
ok(r == TRUE, "expected %d, got %d le=%lu\n", TRUE, r, GetLastError());
|
||||
r = EmptyClipboard();
|
||||
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
||||
|
|
Loading…
Add table
Reference in a new issue